PDA

View Full Version : Determine when <Enter> pressed in stringfield? Is there a better text entry field?



zuilin
October 14th, 2020, 06:58
I'm using a stringfield to have the user enter a string of text. I want to do something with it when they press <Enter>. However, what happens now is that when <Enter> is pressed, the text becomes highlighted.

I looked in the API and there is a onValueChanged() callback for stringcontrol which stringfield inherits, and the ref doc says:


Is called when the value of the string inside the control changes. This may result from finishing the editing of the string or the value changing externally from the control.

When I test this, every character entered into the stringfield triggers onValueChanged(), not just "...result from finishing the editing of the string..." like it says.

Two (ok, three) questions:

1. Is there any way to detect when <Enter> is pressed and then do something with the entered string at that moment?

2. If this isn't the control that can do this, but here is a better one, which one is it?

3. Is there some other means to accomplish this?

Thanks.

Moon Wizard
October 14th, 2020, 07:24
Have tried handling this event?
https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4096428/textbasecontrol#onEnter

Regards,
JPG

zuilin
October 14th, 2020, 14:40
Bah. I’m a dummy. Somehow I missed onEnter. Didn’t realize the inheritance tree there. Thanks Moon Wizard.