Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

mouseWheel event only fires after the user clicks the mousewheel

Joshua.mursic
Advocate

mouseWheel event only fires after the user clicks the mousewheel

Joshua.mursic
Advocate
Advocate

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()

 

0 Likes
Reply
Accepted solutions (1)
256 Views
2 Replies
Replies (2)

kandennti
Mentor
Mentor
Accepted solution

Hi @Joshua.mursic -San.

 

I use a cheap scrolling mouse and the event occurred without clicking the wheel.

0 Likes

Joshua.mursic
Advocate
Advocate

Thank you @kandennti, I will buy a different mouse.

1 Like