TextBoxCommandInput bottom border not rendered for numRows > 4

TextBoxCommandInput bottom border not rendered for numRows > 4

william-c-anderson
Advocate Advocate
800 Views
5 Replies
Message 1 of 6

TextBoxCommandInput bottom border not rendered for numRows > 4

william-c-anderson
Advocate
Advocate

The bottom border line of a TextBoxCommandInput is not rendered if the number of lines displayed is greater than 4. I've looked but I've found no policy or documentation for this behavior. Is there some way to get the code to draw the lower border?

0 Likes
801 Views
5 Replies
Replies (5)
Message 2 of 6

kandennti
Mentor
Mentor

Hi @william-c-anderson .

 

The state could not be reproduced.
Is there a simple sample code?

0 Likes
Message 3 of 6

william-c-anderson
Advocate
Advocate

I'm happy to supply you with a test case, @kandennti-san. Here is a little script adapted from the API sampler which shows the problem. Type a new number into the text box to reset numRows.

#Author-William Anderson
#Description-Shows failure of TextBoxCmd to draw bottom border if numRows > 4

import adsk.core, adsk.fusion, adsk.cam, traceback

_handlers = []

class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            # Get the command that was created.
            cmd = adsk.core.Command.cast(args.command)

            # Connect to the input changed event.           
            onInputChanged = MyCommandInputChangedHandler()
            cmd.inputChanged.add(onInputChanged)
            _handlers.append(onInputChanged)    

            # Get the CommandInputs collection associated with the command.
            inputs = cmd.commandInputs

            # Create an editable textbox input.
            myBox = inputs.addTextBoxCommandInput('writable_textBox', 'myTextBox', '5', 5, False)
            myBox.isFullWidth = False
        except:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

class MyCommandInputChangedHandler(adsk.core.InputChangedEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            eventArgs = adsk.core.InputChangedEventArgs.cast(args)
            inputs = eventArgs.inputs
            cmdInput = eventArgs.input
            cmdId = cmdInput.id

            if cmdId == 'writable_textBox':
				# read number and reset number of lines displayable
                textBox = adsk.core.TextBoxCommandInput.cast(cmdInput)
                text = textBox.text
                try:
                    rows = int(text)
                    textBox.numRows = max(rows, 1)
                except:
                    pass
                  
        except:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface

        # Get the existing command definition or create it if it doesn't already exist.
        cmdDef = _ui.commandDefinitions.itemById('textBoxTest')
        if not cmdDef:
            cmdDef = _ui.commandDefinitions.addButtonDefinition('textBoxTest', 'TextBox Texter', '')

        # Connect to the command created event.
        onCommandCreated = MyCommandCreatedHandler()
        cmdDef.commandCreated.add(onCommandCreated)
        _handlers.append(onCommandCreated)

        # Execute the command definition.
        cmdDef.execute()

        # Prevent this module from being terminated when the script returns, because we are waiting for event handlers to fire.
        adsk.autoTerminate(False)
    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
Message 4 of 6

kandennti
Mentor
Mentor

Thank you @william-c-anderson .

 

This phenomenon seems to occur when the last of CommandInputs is TextBoxCommandInput.
If something else exists below, the line below is also displayed.
Added ImageCommandInput to display 1 pixel image for trial.

class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
・・・
            # Create an editable textbox input.
            myBox = inputs.addTextBoxCommandInput('writable_textBox', 'myTextBox', '5', 5, False)
            myBox.isFullWidth = False
inputs.addImageCommandInput('dmy', '', "resources/dmy.png") except: _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

1.png

 

It can do its job, but it also wastes space.
There seems to be no other way but to make TextBoxCommandInput not at the end.

 

 

0 Likes
Message 5 of 6

william-c-anderson
Advocate
Advocate

Thanks, @kandennti , for the fast reply. Should this be filed as a (presumably low priority) defect?

0 Likes
Message 6 of 6

kandennti
Mentor
Mentor
0 Likes