TextBoxCommandInput.isEnabled not working as described

TextBoxCommandInput.isEnabled not working as described

danielWNW3M
Contributor Contributor
262 Views
2 Replies
Message 1 of 3

TextBoxCommandInput.isEnabled not working as described

danielWNW3M
Contributor
Contributor

Hopefully this is a simple problem, but what I functionally want to do is use the .hasFocus method I've used in the past for selection inputs. It works great for them, but after digging through a bunch of errors I realized the method just doesn't seem to exist for text inputs.

 

Since I was in the documentation anyway (https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-a10df443-c843-4733-9111-6332f9410db2), I found the line below, saying that the .isEnabled method does exactly what I want. Perfect!

Screenshot 2025-03-03 at 5.22.16 PM.png

I'm struggling to get it to work though - it seems to be doing what the first sentence describes. Has this function been updated (and not the documentation) or am I using it wrong?

 

Also, if it has been updated, is there a way to replicate the .hasFocus method with text inputs?

 

Thanks a bunch for any help!

 

 

 

 

If necessary here's my implementation, it's pretty straight forward:
creating the input:

    inputs.addTextBoxCommandInput('filepath', 'Path to write to:', f'Users/{username}/Downloads', 1, False)
    inputs.addTextBoxCommandInput('creatorName', 'Creator Name', '', 1, False)
    inputs.addTextBoxCommandInput('creatorEmail', 'Creator Email', '', 1, False)
    inputs.addTextBoxCommandInput('description', 'Description', desc, 1, False)
    inputs.addTextBoxCommandInput('releaseNotes', 'Release Notes', '', 1, False)

trying to change the focus:

def command_input_changed(args: adsk.core.InputChangedEventArgs):
    changed_input = args.input
    inputs = args.inputs

    textInputs = ['filepath', 'creatorName', 'creatorEmail', 'description', 'releaseNotes']
    if changed_input.id in textInputs:
        if changed_input.text[-1] == '\t':
            changed_input.text = changed_input.text[:-1]
            next_input = textInputs[textInputs.index(changed_input.id) + 1]
            ui.messageBox(f'Tab detected in {changed_input.id}, moving to {next_input}')
            inputs.itemById(next_input).isEnabled = True
0 Likes
Accepted solutions (1)
263 Views
2 Replies
  • API
Replies (2)
Message 2 of 3

en9y37
Advocate
Advocate
Accepted solution

Hi @danielWNW3M 

 

If you mean that you expect a leap of the cursor into the next TextBoxCommandInput when you press the Tab key, lately I've been dealing with the same issue.

 

I've solved it using the StringValueCommandInput object in the inputs instead of TextBoxCommandInput object. If so, you don't even need to program anything in the command_input_changed method to force the leap between command inputs.

 

In my case, all of my StringValueCommandInput objects are embedded in a TableCommandInput, and it works as expected.

 

Hopefully it will work for you too.

Message 3 of 3

danielWNW3M
Contributor
Contributor

This worked! I don't know why I'd never tried that before, thanks a bunch!

0 Likes