Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Choosing focus on selection input not working

3 REPLIES 3
Reply
Message 1 of 4
siliconlad
323 Views, 3 Replies

Choosing focus on selection input not working

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

 

 

3 REPLIES 3
Message 2 of 4
kandennti
in reply to: siliconlad

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
in reply to: siliconlad

Is this a bug then?

Message 4 of 4
rusty.bird
in reply to: siliconlad

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report