I know that I can see if a particular widget has control in SWT by using isFocusControl()
on it. However, when my expected widget doesn't have focus, how can I determine what does (in other words, what took the focus away)?
I'm able to handle keyboard events with traverse listeners, but changing focus using clicks of the mouse appears to mystify my application. I can't seem to figure out how to find the item that took the focus from the previous item.
I'm also having issues with reliably setting focus to another widget from within a FocusLost
listener if the focus is changed by a mouse event.
Any suggestions?
It is:
Display.getFocusControl();
As explained, Display.getFocusControl() tells you which Control has focus. You can associate information with widgets via the setData() methods. You can do this with every control that could possibly get focus and then getData() should help you figure out what control has the focus.
Otherwise you can just keep pointers to the controls that you created and compare the pointer to your known control pointers, no?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With