Java(SWT) - Control key + M on the keyboard triggers double-click functionality on Tree Items in SWT
I have a double-click functionality for the tree viewers wherein the tree items expand\collapse when I double-click on them, but when I press CTRL+M on the keyboard even then the tree items expand\collapse, My code for double-clicking tree items is as follows:
private class DoubleClickListener implements IDoubleClickListener
{
@Override
public void doubleClick(final DoubleClickEvent event)
{
final IStructuredSelection selection = (IStructuredSelection)event.getSelection();
if (selection == null || selection.isEmpty())
return;
final Object sel = selection.getFirstElement();
final ITreeContentProvider provider = (ITreeContentProvider)treeViewer.getContentProvider();
if (!provider.hasChildren(sel))
return;
if (treeViewer.getExpandedState(sel))
treeViewer.collapseToLevel(sel, AbstractTreeViewer.ALL_LEVELS);
else
treeViewer.expandToLevel(sel, 1);
}
}
I can supress CTRL+M through adding key listener but my question is as follows :
This behavior (CTRL+m expanding tree items) only happens When I use the IDoubleClickListener interface and override the method doubleClick(), but the same behavior (CTRL+m expanding tree items) does not happen when I use : addMouseListener(new MouseListener()) and override the method : mouseDoubleClick(). Is the behavior (CTRL+m) expanding tree items related to IDoubleClickListener interface(If so what is the reason) or is this problem generic? I feel it should not be related to IDoubleClickListener, Can someone please tell me why is there a difference in using these two logic?