Java(SWT) - Control key + M on the keyboard triggers double-click functionality on Tree Items in SWT


Forum Post 0 Answers 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?

- prithvirulzzz May 15, 2014 | Flag |






Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More