Fabian Zeindl
Fabian Zeindl

Reputation: 5988

SWT: addFilter or addKeyListener on Composite

i want to have some composite-wide keyboard-shortcuts. The composites in question are in a tab-folder. I have a little function, which traverses all children of my composite and adds a KeyboardAdapter to every one of them.

The problem I have is that, when I open on of the tabs pressed keys aren't registered. I first have set the focus on some selectable widget in the tab, then it works. When i switch to another tab and then back, the focus is still kind of there (a grey selection instead of a blue one in a table for example), but it, again, doesn't work, until i click somewhere.

How can I do this? I thought about adding a filter to my display, but i only want events in a certain composite (and everything in there).

Thank you

Upvotes: 1

Views: 954

Answers (1)

Gorkem Ercan
Gorkem Ercan

Reputation: 3226

Key events are delivered to the component that has keyboard focus. Composites do not get the keyboard focus, it is usually one of their child components that gets it and then they start receiving the key events (in case they are not used by children). Having the key listener on the parent Shell may possibly work.

Upvotes: 3

Related Questions