-
21 Apr 2011 12:21 AM #1
Dynamic Context in Tree. How to Prevent show after Event ?
Dynamic Context in Tree. How to Prevent show after Event ?
Hello,
i have a dynamic context menu on each node. Sometime its to possible to get a context menu without any items. Sadly the context menu show a clear rect on the screen.
How its possible to prevent this ?
Here my Code:
Code:Menu contextMenu = new Menu(); tree.addListener(Events.ContextMenu, new Listener<ComponentEvent>() { public void handleEvent(ComponentEvent be) { Object selectedObject = tree.getSelectionModel().getSelectedItem(); Menu contextMenu = cfactory.createContextMenuselectedObject); addNewEntriesMenu(contextMenu,selectedObject); if (contextMenu.getItemCount()==0) { //tree.setContextMenu(null); // cant set to null cause no more events fired. // add usefull thing here to prevent show contextmenu } tree.setContextMenu(contextMenu); } }); tree.setContextMenu(contextMenu);
-
21 Apr 2011 12:54 AM #2
You can simple cancel the Events.ContenxtMenu event if you dont want to open the menu.
-
21 Apr 2011 1:14 AM #3
Hello Sven,
fast reply thx.
this code doesnt work. Any idea.
regardsCode:if (contextMenu.getItemCount()==0) { be.stopEvent(); be.getEvent().stopPropagation(); return; }
meLast edited by Mebel; 21 Apr 2011 at 1:15 AM. Reason: Format Problems. Preview pos doesnt work ?
-
21 Apr 2011 1:30 AM #4
because you have not cancelled it. None of the methods you called contain the word cancelled

what aboutCode:be.setCancelled(true);
-
21 Apr 2011 1:34 AM #5
yes looks like a self created easter egg.
Work well now. thx.
Happy Easter
me
Similar Threads
-
How to show Context Menu without triggering a Selection event
By gbegley in forum Ext GWT: DiscussionReplies: 1Last Post: 27 Oct 2010, 2:08 PM -
How to dynamic change context menu after tree node init.
By qgj2046 in forum Ext 2.x: Help & DiscussionReplies: 5Last Post: 14 Sep 2009, 6:09 PM -
Dynamic context menu on tree not allowed?
By sgolla in forum Ext GWT: DiscussionReplies: 5Last Post: 11 Jul 2009, 1:27 AM -
tree context menu event acting on tree
By garyrgi in forum Ext 1.x: Help & DiscussionReplies: 5Last Post: 21 May 2007, 11:15 PM


Reply With Quote