How to catch the key pressed in a context menu? #389
Unanswered
wimjongman
asked this question in
Q&A
Replies: 2 comments 3 replies
-
Have you tried https://github.com/eclipse-platform/eclipse.platform.swt/blob/master/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet25.java ? Note: display filters shouldn't be used for such "trivial" things like listening on key events in your own widget |
Beta Was this translation helpful? Give feedback.
1 reply
-
The same trick but now on shell. Notice that the listeners stop working if the shell loses and regains focus. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The main question is: How can I get the state of the shift key when populating a context menu.
My context menu must be populated based on the press of the shift key.
The only way I found to catch the shift key is to add a Display filter on the keyup and keydown events:
This works fine most of the time. However, as soon as the context menu is shown, the keyUp event is not processed.
This means that my fShift boolean stays true if I let go of the shift key when the context menu is shown.
See attached snippet. Is there another way to grab the shift key state when I am in my context menu?
ATest.java.txt
Beta Was this translation helpful? Give feedback.
All reactions