只是爲了子孫後代:
我跟Greg的意見,並添加KeyListsner給觀衆控制。這是我的課的片段,它包裝StructuredViewer:
private class ViewerWrapper{
private StructuredViewer fViewer;
[...]
private class ViewerKeyAdapter implements KeyAdapter{
private int fKeyCode;
private Action fAction;
private int fStateMask;
public ViewerKeyAdapter(int keyCode, int stateMask, Action action){
fKeyCode = keyCode;
fStateMask = stateMask;
fAction = action;
}
@Override
public void keyReleased(KeyEvent e) {
if((e.stateMask & fStateMask) != 0 || fStateMask == SWT.NONE){
if(e.keyCode == fKeyCode){
fAction.run();
}
}
}
}
[...]
public void addKeyListener(int keyCode, int stateMask, Action action){
fViewer.getControl().addKeyListener(new ViewerKeyAdapter(keyCode, modifier, action));
}
}
大部分時間我在這個花的時間是要認識到,SWT.UP
和SWT.ARROW_UP
是不一樣的......
不能像沒有完成影響plugin.xml?另外我找不到org.eclipse.ui.keys延伸點。 org.eclipse.ui.commands中有keyBinding項。它可以用來代替嗎? – Patryk 2014-09-25 10:58:59
抱歉應該是'org.eclipse.ui.bindings'的擴展點。您始終可以處理桌面上的'KeyDown'事件並檢查您的快捷鍵 – 2014-09-28 19:48:27