- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is anyone else having an issue where the mouseWheel event only starts to fire after the user has clicked the mouse wheel? Here is a test script.
import adsk.core, adsk.fusion, adsk.cam
app = adsk.core.Application.get()
ui = app.userInterface
handlers = []
class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
def __init__(self):
super().__init__()
def notify(self, args:adsk.core.CommandCreatedEventArgs):
cmd = args.command
cmd.isExecutedWhenPreEmpted = False
inputs = cmd.commandInputs
textInput = inputs.addTextBoxCommandInput('textBoxId', 'Wheel Test', 'Test the wheel', 1, True)
# Connect to the command related events.
mouseWheelEvent = MyMouseScrollHandler(textInput)
cmd.mouseWheel.add(mouseWheelEvent)
handlers.append(mouseWheelEvent)
class MyMouseScrollHandler(adsk.core.MouseEventHandler):
def __init__(self, textInput):
super().__init__()
self.input:adsk.core.TextBoxCommandInput = textInput
def notify(self, args: adsk.core.MouseEventArgs):
self.input.formattedText = f'Wheel Delta = {args.wheelDelta}'
class MyCommandDestroyHandler(adsk.core.CommandEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
adsk.terminate()
def run(context):
app = adsk.core.Application.get()
ui = app.userInterface
cmdId = "testWheel"
cmd_def = ui.commandDefinitions.itemById(cmdId)
if cmd_def is not None:
cmd_def.deleteMe()
cmd_def = ui.commandDefinitions.addButtonDefinition(cmdId, "Test Wheel", '', '')
# Connect to the command created event.
onCommandCreated = MyCommandCreatedHandler()
cmd_def.commandCreated.add(onCommandCreated)
handlers.append(onCommandCreated)
# Execute the command.
cmd_def.execute()
Solved! Go to Solution.