Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Context menu on a tree

    Hi i just tried to add a context menu to TreeGrid but no success. Default browser menu shows up.
    Code:
    Menu menu = new Menu();
    menu.setShowShadow(true);
    menu.setShadowDepth(10);
    		
    MenuItem newItem = new MenuItem("New", "icons/16
    menu.setItems(newItem);
    treeGrid.setContextMenu(menu);
    Code:
    Global Log Priorities updated: Logging messages at priority 'Info' and above for category 'EventHandler'.
    18:17:31.708:MDN4:INFO:EventHandler:Target Canvas for event 'mousedown': [TreeGridBody ID:isc_OID_0_body]
    18:17:31.942:MUP9:INFO:EventHandler:Target Canvas for event 'mouseup': [TreeGridBody ID:isc_OID_0_body]
    18:17:31.942:CXT0:INFO:EventHandler:Target Canvas for event 'contextmenu': [TreeGridBody ID:isc_OID_0_body]

    #2
    Please ignore, works as designed. It helps to add the menu on the correct tree !

    Comment


      #3
      ok, where is the trusted TreeNode? Event doesn't let me know what node on the tree i right-clicked on. Event only knows about the treeGrid.

      Code:
      MenuItem newItem = new MenuItem("New", "icons/16/add.png", "Ctrl+N");
      newItem.addClickHandler(new ClickHandler() {
          public void onClick(MenuItemClickEvent event) {
               System.out.println("event.source: " + event.getTarget());
               System.out.println("event.colNum: " + event.getColNum());
               System.out.println("event.type: " + event.getType());
          }
      });

      Comment


        #4
        Never mind once again:
        TreeGrid treeGrid = (TreeGrid)event.getTarget();
        System.out.println(treeGrid.getSelectedRecord());

        right clicking selects the item at the same time. Thankfully.

        Comment

        Working...
        X