Numeric Text Field: Focus stays despite changing value

I am using a bi-directional numeric text field on my touch-screen monitor. Everything works fine in-terms of the values changing!

When I press the NTF, a key-pad appears. I can enter a new value or press cancel. When I do either of those tasks, the text in the NTF stays selected/focused (see pic)

It doesn’t affect any functionalities but it doesn’t look good and the only way to get rid of it is by re-opening the window.

I haven’t used keypads before but I would think you could call requestFocusInWindow() on some other component (might even work on a hidden component) when the keypad closes and that would solve the problem.

Edit: I just tried it with a component that was set to visible=False and it didn’t work. However, you could put a component underneath another component and that would work. The component on which you set focus would technically still be visible but the user could not see it.

[quote=“JGJohnson”]I haven’t used keypads before but I would think you could call requestFocusInWindow() on some other component (might even work on a hidden component) when the keypad closes and that would solve the problem.

Edit: I just tried it with a component that was set to visible=False and it didn’t work. However, you could put a component underneath another component and that would work. The component on which you set focus would technically still be visible but the user could not see it.[/quote]

I tried the following script on propertyChange but it didn’t work

if event.propertyName == "value": event.source.parent.getComponent('Label').requestFocusInWindow()

It didn’t work when the label was visible or invisible!

[quote=“oxanemi”]

It didn’t work when the label was visible or invisible![/quote]

I don’t think requestFocusInWindow() works on components that don’t accept user input. You would have to use a text field or something and then “hide” it (move it to the back of the z-order) behind another component on your screen. It worked when I tested it.

It looks like to do this, you may need to turn off the Touch screen functionality of the project.
You could try to get this to work by unchecking the “Touch Screen” options for the project.
Then try adding the following code to the mouseClicked event:

event.source.intValue = system.gui.showNumericKeypad(event.source.intValue)
system.gui.getParentWindow(event).rootContainer.getComponent("txthidden").requestFocusInWindow()

In this case, txthidden is a Text Field hidden behind another object, as suggested by JGJohnson.

Maybe we should ask for a Feature Request that allows the designer to handle
TouchscreenKeyboard and NumericKeypad events as they are completed.