Opened 10 years ago

Closed 10 years ago

#8388 closed defect (fixed)

Tree: Context Menu on DnD enabled Tree

Reported by: rsaccon Owned by: bill
Priority: high Milestone: 1.3
Component: Dijit Version: 1.2.3
Keywords: Tree, DnD, Menu Cc:
Blocked By: Blocking:

Description

While it is possible to add ContextMenu? to a Tree, once I add a Dnd controller (dijit._tree.dndSource), ContextMenus? fail silently. I am using dojo trunk and testing on latest firefox.

Attachments (4)

test_Tree_DnD.html (9.4 KB) - added by bill 10 years ago.
modified version of test_Tree_Dnd.html, with context menu on tree nodes.
Picture 1.png (8.3 KB) - added by rsaccon 10 years ago.
The blue line from firebug insector covers full domNode area of tree (including area outisde treenodes)
Picture 2.png (7.9 KB) - added by rsaccon 10 years ago.
here we have the area of a treenode (where opening contextmenu fails)
Picture 3.png (18.8 KB) - added by rsaccon 10 years ago.
inside container from first screenshot, but outside treenode, contextmenu works

Download all attachments as: .zip

Change History (19)

comment:1 Changed 10 years ago by bill

Component: GeneralDijit
Owner: anonymous deleted
Summary: Context Menu on DnD enabled TreeTree: Context Menu on DnD enabled Tree

comment:2 Changed 10 years ago by rsaccon

Further testing revealed that this works fine on Safari 3.2.1, (but still fails in FF 3)

comment:3 Changed 10 years ago by rsaccon

and if the Contextmenu is invoked vie keyboad (Ctrl space on Mac), then it pops up as expected, even on FF. I think this is because in such a case, the 'contextmenu' DOM event fires, but in case of MouseRight? pressed, only on Safari contextmenu gets fired, on Firefox just normal DOM mouse events get fired.

comment:4 Changed 10 years ago by bill

Resolution: worksforme
Status: newclosed

It works for me. See attached code.

Can you attach a test case where it fails?

Changed 10 years ago by bill

Attachment: test_Tree_DnD.html added

modified version of test_Tree_Dnd.html, with context menu on tree nodes.

comment:5 Changed 10 years ago by rsaccon

Resolution: worksforme
Status: closedreopened

No, it does not work for me ! On Mac OS X 10.5.6 / Firefox 3.0.6, when I click right mouse button on a treenode, I get NO context menu (not even the default one one from the browser). If I click on a area which belongs to the tree container, but is not a treenode, then I get the context menus (I guess this is what happened when it apparently worked). No I really hope I am wrong and I just did a stupid mistake ...

comment:6 Changed 10 years ago by bill

Are you saying that the test case I attached doesn't work for you?

comment:7 Changed 10 years ago by rsaccon

Yes, that is exactly what I am saying. And in my app in development I have the same behavior.

comment:8 Changed 10 years ago by bill

Hmm, can you try against the latest code? In the latest code there is no "area which belongs to the tree container, but is not a treenode".

comment:9 Changed 10 years ago by rsaccon

Ok, was using very recent rev, but now I verified again, with rev. 16580 and took some screenshots while inspecting things with Firebug, will attach them to this post.

I also got this error message in Firebug, while trying to open the menu on a treenode:

tn.item is undefined [Break on this error] (575 out of range 472)

Changed 10 years ago by rsaccon

Attachment: Picture 1.png added

The blue line from firebug insector covers full domNode area of tree (including area outisde treenodes)

Changed 10 years ago by rsaccon

Attachment: Picture 2.png added

here we have the area of a treenode (where opening contextmenu fails)

Changed 10 years ago by rsaccon

Attachment: Picture 3.png added

inside container from first screenshot, but outside treenode, contextmenu works

comment:10 Changed 10 years ago by bill

Hmm, I don't know, it's working for me on the TreeNode? too. The only apparent difference between our environments is Tiger vs. Leopard for the OS.

The code where it's failing for you is in the test file:

dojo.connect(menu, "_openMyself", this, function(e){
	// get a hold of, and log out, the tree node that was the source of this open event
	var tn = dijit.getEnclosingWidget(e.target);
	console.debug(tn);

	// now inspect the data store item that backs the tree node:
	console.debug(tn.item);

You said that tn.item is undefined, but what is tn? What is e.target?

comment:11 Changed 10 years ago by rsaccon

Great to have you troubleshooting that with me, so first I disabled Firebug to make sure it is not Firebug causing the problems (it is not), then I went to discover about the other event objects you asked and here is what I found out:

right mouse click on treenode, _openMyself is NOT fired at all (none of the debug statements get called), when clicking outside of treenode, I get:

e.target: ========= <div id="itemTree" class="dijitTreeContainer container dojoDndSource dojoDndTarget dojoDndContainerOver" dojoattachevent="onclick:_onClick,onkeypress:_onKeyPress,ondblclick:_onDblClick" wairole="tree" role="tree" widgetid="itemTree" aria-expanded="true">

tn: === [Widget dijit.Tree, itemTree] _connects=[8] _deferredConnects=Object id=itemTree

tn.item: ======== undefined

(that makes sense, because only tree nodes have a datastore item associated with them, in my app I associate the last selected treenode with a datastore item for that case)

comment:12 Changed 10 years ago by bill

Ok... yes, right-clicking that sort of "margin" around the tree makes the code in the test file fail b/c it's expecting a TreeNode to be clicked. That's just a bug in the test file, nothing to do with Tree itself.

As for why your right click on the TreeNode? isn't responding, I think I figured out what the difference is. You must have an actual mouse plugged into your mac instead of using the touchpad. Touchpad is working fine for you, yes?

comment:13 Changed 10 years ago by rsaccon

Yes, with touchpad it works fine.

comment:14 Changed 10 years ago by bill

Milestone: tbd1.3
Owner: set to bill
Status: reopenednew

Ah OK, I see it, and I have a simple fix. As you alluded to it deals with the mousedown event... the problem is that the DnD code calls dojo.stopEvent() on the mousedown event which also cancels the context menu event.

I opened #8603 to track this issue in the root DnD code (as this problem extends beyond just Tree), but I'll fix the Tree issue with this ticket.

comment:15 Changed 10 years ago by bill

Resolution: fixed
Status: newclosed

(In [16624]) Fix issue where Tree's DnD code prevents having context menus on tree nodes.

A mouse press of the right mouse button, when done with a real mouse, on mac, causes both a mousedown event and a contextmenu event. On FF3, calling dojo.stopEvent() on the mousedown event also cancels the contextmenu event.

Even if that weren't an issue, the DnD code shouldn't be doing anything on right-mousedown events.

Left mouse-down has evt.button == 1 or evt.button == 0 depending on IE or FF/safari, but right-mouse always seems to be evt.button == 2, so checking that way.

Fixes #8388, refs #8603 !strict.

Note: See TracTickets for help on using tickets.