SWT:Composite上的addFilter或addKeyListener [英] SWT: addFilter or addKeyListener on Composite

查看:163
本文介绍了SWT:Composite上的addFilter或addKeyListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一些组合范围的键盘快捷键.有问题的复合材料在选项卡式文件夹中.我有一个小功能,它遍历我复合材料的所有子代,并向每个子代添加一个KeyboardAdapter.

我的问题是,当我打开选项卡中的某个时,未注册按键.我首先将焦点放在选项卡中的一些可选窗口小部件上,然后工作了.当我切换到另一个选项卡然后再返回时,焦点仍然在那里(例如,灰色选择而不是表格中的蓝色选择),但是直到我单击某处之后,它才再次起作用.

我该怎么做?我曾考虑过要在显示器上添加一个过滤器,但是我只想要特定组合中的事件(以及其中的所有内容).

谢谢

解决方案

键事件传递到具有键盘焦点的组件.合成无法获得键盘焦点,通常是获得其焦点的子组件之一,然后它们开始接收按键事件(以防子不使用它们).在父Shell上具有键侦听器可能会起作用.

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

解决方案

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.

这篇关于SWT:Composite上的addFilter或addKeyListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆