Choosing focus on selection input not working

Choosing focus on selection input not working

siliconlad
Contributor Contributor
969 Views
3 Replies
Message 1 of 4

Choosing focus on selection input not working

siliconlad
Contributor
Contributor

I have two SelectionCommandInput as follows:

siliconlad_0-1708966859317.png

When the dialog is created, I would like to have the "Bodies" SelectionCommandInput to be selected.

 

To do this, I tried to make use of the `hasFocus` attribute, but that doesn't seem to work. `isEnabled` didn't work either. Am I doing something wrong? The following code is what I used.

 

# Function that is called when a user clicks the corresponding button in the UI.
# This defines the contents of the command dialog and connects to the command related events.
def command_created(args: adsk.core.CommandCreatedEventArgs):
    # General logging for debug.
    futil.log(f'{CMD_NAME} Command Created Event')

    # TODO Connect to the events that are needed by this command.
    futil.add_handler(args.command.execute, command_execute, local_handlers=local_handlers)
    futil.add_handler(args.command.destroy, command_destroy, local_handlers=local_handlers)

    # https://help.autodesk.com/view/fusion360/ENU/?contextId=CommandInputs
    inputs = args.command.commandInputs

    selectInput_1 = inputs.addSelectionInput(f"Selection_1", "Occurrences", f"Select Occurrences")
    selectInput_1.addSelectionFilter("Occurrences")
    selectInput_1.setSelectionLimits(0, 0)

    selectInput_2 = inputs.addSelectionInput(f"Selection_2", "Bodies", f"Select Bodies")
    selectInput_2.addSelectionFilter("Bodies")
    selectInput_2.setSelectionLimits(0, 0)
    selectInput_2.hasFocus = True

 

 

0 Likes
970 Views
3 Replies
Replies (3)
Message 2 of 4

kandennti
Mentor
Mentor

Hi @siliconlad -San.

 

I tried with a script and was able to reproduce the same phenomenon.
I thought of setting the focus not on the CommandCreated event, but on the Activate event that occurs afterwards, but the focus was still returned to selectInput_1 in the same way.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-eeb18ad8-6ea6-4a35-923f-c96113549704 

Message 3 of 4

siliconlad
Contributor
Contributor

Is this a bug then?

0 Likes
Message 4 of 4

rusty.bird
Advocate
Advocate

I am having the same issue when I try and set hasFocus() inside my CommandCreatedEventHandler.  Any solutions?  

0 Likes