Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Disabling Treeviewer doubleclick expand/collapse(Disabling Treeviewer doubleclick expand/collapse)
Disabling Treeviewer doubleclick expand/collapse [message #749184] Tue, 25 October 2011 04:34 Go to next message
Greg Babcock is currently offline Greg Babcock
Messages: 53
Registered: July 2009
Member
I am using a treeviewer in my application to perform in-place editing with double click editor activation. On windows 7 when I double click in a cell to activate the in-place editor, the tree node inappropriately expands/collapses.

Is it possible to disable expand/collapse on double click? I don't remember having this problem before moving to windows 7 from XP.
Re: Disabling Treeviewer doubleclick expand/collapse [message #753395 is a reply to message #749184] Thu, 27 October 2011 02:55 Go to previous message
Greg Babcock is currently offline Greg Babcock
Messages: 53
Registered: July 2009
Member
I think this is a bug, but I found a workaround. I found this in the Tree class where double click events get filtered out if the tree has an event listener of type SWT.MeasureItem.

	
case OS.NM_DBLCLK: {
			/*
			* When the user double clicks on a tree item
			* or a line beside the item, the window proc
			* for the tree collapses or expand the branch.
			* When application code associates an action
			* with double clicking, then the tree expand
			* is unexpected and unwanted.  The fix is to
			* avoid the operation by testing to see whether
			* the mouse was inside a tree item.
			*/
			if (hooks (SWT.MeasureItem)) return LRESULT.ONE;

Adding this to my treeviewer solved the problem:
	
		treeViewer.getControl().addListener(SWT.MeasureItem, new Listener(){
			@Override
			public void handleEvent(Event event) {
				
			}});

BTW: If you treeviewer uses an OwnerDrawLabelProvider it will add the SWT.MeasureItem for you.
Previous Topic:Smooth updating treeviewer with DeferredTreeContentManager
Next Topic:Scrolled Form
Goto Forum:
  


Current Time: Tue Sep 16 03:00:44 GMT 2014

Powered by FUDForum. Page generated in 0.01547 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software