在 Eclipse 中禁用 TreeViewer 的 Alt+Enter
我已经在 SWT 中的树中添加了一个按键侦听器,当我按 Alt+Enter 时,按键事件的状态为 keyCode = 65536 且 statemask = 0,而它应该是 keyCode='\r'和状态掩码=65536。
下面是我编写的代码片段 -
mViewer.getTree().addListener(SWT.KeyDown, new Listener() {
@Override
public void handleEvent(Event e) {
if(e.keyCode == SWT.CR && e.stateMask == SWT.ALT) {
e.doit = false;
}
}
});
Eclipse 工作台在将事件委托给组件中的侦听器之前过滤一些事件。有没有一种方法可以禁用 alt+enter 以不在其中一个树查看器上执行 eclipse 中的显示属性?
此致, 克沙夫
I have added a key listener to a tree in SWT and when i press Alt+Enter the state of the key event is keyCode = 65536 and statemask = 0, when it should have been keyCode='\r' and statemask=65536.
Below is the code snippet i have written-
mViewer.getTree().addListener(SWT.KeyDown, new Listener() {
@Override
public void handleEvent(Event e) {
if(e.keyCode == SWT.CR && e.stateMask == SWT.ALT) {
e.doit = false;
}
}
});
Eclipse workbench filters some of the events before delegating the events to the listeners in the components. Is there a way i can disable the alt+enter to not execute the show properties in eclipse on one of the treeviewers?
Best Regards,
Keshav
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过多种不同的方式覆盖特定查看器的特定全局命令:
Display
过滤器来执行相同的操作 - 可以在查看器控件的焦点输入/输出处添加/删除过滤器。我更喜欢最后一个解决方案,因为我可以覆盖新上下文的特定键绑定使用普通绑定扩展点的任何插件的查看器...
You can override a specific global command for a specific Viewer is many different ways:
Display
filter to do the same - the filter can be added/removed at the focus in/out on the control of the Viewer.I prefer this last solution as I can override specific key bindings for the Viewer from any plug-in using the normal binding extension point...
尝试以下代码:
以及您需要的导入:
Try the following code:
And the imports you need:
您将看到所有按键/按下事件 - 即使该键是状态键。所以第一个事件是
Alt
键按下...顺序应该是:
You will see all the key/down events - even if the key is a state key. So the first event is for the
Alt
key down...The sequence should be: