Announcement

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

    IconMenuButton icon click doesn't fire ClickHandler unlike ToolStripMenuButton

    Hi,

    When clicking the icon on the ToolStripMenuButton, its ClickHandler is fired (OK).
    The same code for an IconMenuButton doesn't fire its ClickHandler.

    Is this intended?


    Repro: clicking the IconMenuButton's arrow doesn't do anything.
    Code:
    IconMenuButton btn = new IconMenuButton("No Color Change");
    btn.setShowFocusedAsOver(false);
    final HLayout h = new HLayout();
    h.setWidth(200);
    h.setHeight(200);
    
    btn.addClickHandler(new ClickHandler() {
    	
    	public void onClick(ClickEvent event) {
    		
    		h.setBackgroundColor("red");
    		
    	}
    });
    
    ToolStripMenuButton btn2 = new 		ToolStripMenuButton("Color Change");
    btn2.setShowFocusedAsOver(false);
    
    btn2.addClickHandler(new ClickHandler() {
    	
    	public void onClick(ClickEvent event) {
    		
    		h.setBackgroundColor("red");
    		
    	}
    });
    
    // DOCS for addIconClickHandler
    //If this button is showing an icon, a separate click handler for the icon may be defined as this.iconClick.
    //Returning false will suppress the standard button click handling code.
    
    
    RibbonBar bar = new RibbonBar();
    RibbonGroup group = new RibbonGroup();
    group.setNumRows(2);
    group.setTitle("Group Disabled");
    group.setRowHeight(76);
    group.addControl(btn);
    group.addControl(btn2);
    
    bar.addMember(group);
    
    final VLayout v = new VLayout();
    v.setOverflow(Overflow.VISIBLE);
    v.addMember(bar);
    v.addMember(h);
    The docs for addIconClickHandler say "may be defined", so not needed by default to get the icon click working, I assume?


    v8.3p_2012-11-30/Pro Deployment (built 2012-11-30)


    cheers,

    #2
    The reason this is failing is that the IconMenuButton has a default menu icon click handler which falls through to logic that shows the menu for the item and suppresses the click.

    If you want normal click handling behavior, but still want the menu icon image to appear you should be able to get this via a standard IconButton with showMenuIcon set to true.

    We'll look into whether there's a way to make this behavior cleaner and clearer

    Regards
    Isomorphic Software

    Comment


      #3
      Thanks, I understand.
      To add some info here:
      what I'm doing is lazy load the Menu behind the button, because not many users will 'daily' use this menu anyway.

      So onClick:
      Code:
      if (first time) {
      initialize the menu
      button.setMenu()
      button.showMenu()
      } else {
      button.showMenu()
      }
      I did notice that the button.showMenu() is needed on button click, not when the user clicks the icon (happens automatically, OK of course) - for this case.

      I think when I made this, the ToolStripMenuButton didn't exist yet; so maybe I'll convert that button to use that one instead. That should solve my case eitherway. Just reported this 'issue' because it worked differently.


      cheers,

      Comment


        #4
        We've added IconMenuButton.MenuIconClickEvent which should have been exposed anyway, and clarified the docs a bit for IconMenuButton. This new event is the one you should hook if you want to know when the "menuIcon" arrow button is clicked.

        Comment


          #5
          Thanks for adding, I also found the docs mentioning the MenuIconClickEvent but, not the java class and thought that might have been the solution. Haven't tried it out yet, but found another problem: when disabling the IconMenuButton, but the menuIcon arrow itself doesn't show greyish. Is there another property to disable that one?


          Code:
          IconMenuButton btn = new IconMenuButton("No Disabled Arrow");
          btn.setShowFocusedAsOver(false);
          btn.setDisabled(true);
          
          RibbonBar bar = new RibbonBar();
          RibbonGroup group = new RibbonGroup();
          group.setNumRows(1);
          group.setTitle("Ribbon Group");
          group.setRowHeight(32);
          group.addControl(btn);
          
          bar.addMember(group);
          
          final VLayout v = new VLayout();
          v.setOverflow(Overflow.VISIBLE);
          v.addMember(bar);
          SmartClient Version: v8.3p_2012-11-30/Pro Deployment (built 2012-11-30)


          TIA

          Comment


            #6
            We're aware of this limitation - currently we don't show disabled media for the menu-icon image of a disabled IconMenuButton.
            Support for this is scheduled for addition - no definite ETA yet but when we do have it we should be able to port to the 8.3p branch as well as mainline without too much difficulty.
            We'll keep you posted

            Regards
            Isomorphic Software

            Comment


              #7
              Support for showMenuIconDisabled and showMenuIconOver (both true by default) have been now been added, and the docs tweaked to reflect their usage - changes will hit nightly builds from January 8.

              Comment

              Working...
              X