[CLOSED] ContextMenu in TreePanel shows menu when right click title or toolbar

  1. #1

    [CLOSED] ContextMenu in TreePanel shows menu when right click title or toolbar

    I associated a context menu to my treepanel. Problem is that the context menu shows up when I right click the titlebar or toolbar of the treepanel. I only want it to show when I right click an actual node. The treepanel.contextmenu event does not fire when right clicking titlebar or toolbar. The menu.beforeshow event does not tell me if I am on a node or not.
    Last edited by Daniil; Nov 15, 2011 at 4:54 PM. Reason: [CLOSED]
  2. #2
    Hi,

    How do you show context menu? You can use 'contextmenu' event of TreePanel
    Fires when a node is right clicked. To display a context menu in response to this event, first create a Menu object (see Ext.menu.Menu for details), then add a handler for this event:

    new Ext.tree.TreePanel({ title: 'My TreePanel', root: new Ext.tree.AsyncTreeNode({ text: 'The Root', children: [ { text: 'Child node 1', leaf: true }, { text: 'Child node 2', leaf: true } ] }), contextMenu: new Ext.menu.Menu({ items: [{ id: 'delete-node', text: 'Delete Node' }], listeners: { itemclick: function(item) { switch (item.id) { case 'delete-node': var n = item.parentMenu.contextNode; if (n.parentNode) { n.remove(); } break; } } } }), listeners: { contextmenu: function(node, e) {// Register the context node with the menu so that a Menu Item's handler function can access// it via its parentMenu property. node.select(); var c = node.getOwnerTree().contextMenu; c.contextNode = node; c.showAt(e.getXY()); } }});Parameters

  3. #3
    I am setting ContextMenuID on the TreePanel. The contextmenu event only fires when right clicking a node.
  4. #4
    The contextmenu event only fires when right clicking a node.
    Yes, context menu is snown after right click. What else event do you need? Please provide more details
  5. #5
    When I right click on the treepanel's titlebar or toolbar, the context menu still shows. I dont want the context menu to show in those cases.
  6. #6
    Sorry, but I don't understand why don't you use ContextMenu event to show the context menu?
    Please investigate the following post
    http://forums.ext.net/showthread.php...ull=1#post6344
  7. #7
    Quote Originally Posted by Vladimir View Post
    Sorry, but I don't understand why don't you use ContextMenu event to show the context menu?
    Please investigate the following post
    http://forums.ext.net/showthread.php...ull=1#post6344
    Because I am setting the menu via the TreePanel.ContextMenuID since that should be the preferred and correct way of showing a context menu.
  8. #8
    If you need context menu for a node only then you have to use ContextMenu event and show a menu manually
    ContextMenuID is not preferable way in this case because it is menu for whole widget, it doesn't distinguish any target inside the widget

Similar Threads

  1. Replies: 5
    Last Post: Mar 23, 2011, 9:57 AM
  2. TreePanel and ContextMenu
    By rhnkyr in forum 1.x Help
    Replies: 2
    Last Post: Oct 15, 2009, 9:51 AM
  3. [CLOSED] Contextmenu click coordinates?
    By jcanton in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 09, 2009, 7:49 AM
  4. Replies: 3
    Last Post: May 18, 2009, 2:53 PM
  5. Toolbar menu click problem?
    By dbassett74 in forum 1.x Help
    Replies: 1
    Last Post: Apr 19, 2009, 2:55 AM

Posting Permissions