Ctrl+M is often treated the same as the Return key. The native tree control used by SWT usually treats Return as meaning expand / collapse the current tree node.
To stop this add a KeyListener
to the tree and suppress the unwanted key events:
treeViewer.getTree().addKeyListener(new KeyAdapter()
{
@Override
public void keyPressed(final KeyEvent event)
{
if (event.keyCode == SWT.CR ||
(event.keyCode == 'm' && event.stateMask == SWT.CTRL))
{
event.doit = false;
}
}
});
Update:
Use:
if (e.keyCode == 'm' && e.stateMask == (SWT.CTRL | SWT.SHIFT))
to test for Ctrl+Shift+m
if (e.keyCode == 'm' && e.stateMask == SWT.CTRL)
to test for Ctrl+m
if (e.keyCode == SWT.CR)
to test for Enter.