Question

I am building a json editor in codenameone. In my current design I need to insert or remove components that have focus when a menu command is pressed. So for instance if i have TextFields inside a Container , I need to determine which textfield has focus when I press the insert menu option so that I can insert another component there.

Was it helpful?

Solution

On the current form (you can get the current form using Display.getInstance().getCurrent()) invoke getFocused(). You can also bind a focus listener using addFocusListener on the form or on the component you want to track.

Notice that with touch device the concept of focus isn't quite the same since focus isn't marked on such devices.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top