SWT 菜单中的 KeyListener 或 TraverseListener
我希望能够在 SWT 菜单打开时检测键盘输入(即 TAB 键),但当使用 addListener
方法添加侦听器时,它似乎不会广播任何事件,并且没有 addKeyListener
或 addTraverseListener
方法。
我还尝试将侦听器添加到添加了菜单的控件(它是一个弹出菜单)以及 shell,但按键事件也不会到达这些对象。
看起来菜单是一个操作系统级别的控件,它会占用键盘事件。有没有人找到一种方法从弹出菜单中获取击键?或者是制作我自己的非操作系统弹出菜单的唯一选项?
I'd like to be able to detect keyboard input (namely the TAB key) when an SWT menu is open, but it doesn't seem to broadcast any events when listeners are added with the addListener
method, and there are no addKeyListener
or addTraverseListener
methods.
I've also tried adding listeners to the control to which the menu is added (it's a popup menu) as well as the shell, but key events don't make it to those objects either.
It looks like the menu is an OS level control that eats up keyboard events. Has anyone found a way to grab keystrokes from a popup menu? Or is the only option to make my own non-OS popup menu?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您说得对,SWT 菜单是本机窗口系统菜单。我不确定在这种情况下动词“遍历”是什么意思。您的意思是“突出显示可能的选择”吗?我相信,在 SWT 中,这称为“武装”,您确实可以为武装事件添加侦听器。请参阅此代码段。
如果我完全误解了你的问题,请在评论中告诉我,我会删除。
You are correct that the SWT menu is a native windowing-system menu. I'm not sure what you mean by the verb "traverse" in this context. Do you mean "hilight for possible selection"? I believe that, in SWT, that is called "arming", and you can indeed add listeners for arming events. See this snippet.
If I've completely misunderstood your question, then let me know in a comment, and I'll delete.