Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Posts
    117
    Vote Rating
    0
    tmancini is on a distinguished road

      0  

    Default ToolBar Button onClick override not invoked when Button is in ToolBar overflow menu

    ToolBar Button onClick override not invoked when Button is in ToolBar overflow menu


    I deleted my original post after doing some more research into this issue. The Overflow menu that gets added to the ToolBar seems to contain MenuItems instead of Buttons. I came across the following thread in the EXT JS Bug forums which lead me to this info. I am not entirely sure how I should handle this. I created a Widget that extends ToggleButton and overrides the onClick(Event event) method. Everything works great until the Overflow menu gets created.
    Attached Images

  2. #2
    Sencha User
    Join Date
    Nov 2011
    Posts
    10
    Vote Rating
    0
    Tony Stuart is on a distinguished road

      0  

    Default


    Thank you for bringing this issue to our attention.

    When the number of items on the ToolBar exceeds the number that can be displayed, the ToolBar creates a menu and moves the the items that overflow to the new menu. At this point the ToggleButton's onClick method is no longer invoked. We are reviewing this issue internally to determine the best way to handle this situation.

    In the interim, you can work around the problem by using a SelectHandler instead of an onClick override. Add the SelectHandler to the ToggleButton and move the logic from your onClick override to the onSelect method of the select handler.
    Code:
        addSelectHandler(new SelectHandler() {
          @Override
          public void onSelect(SelectEvent event) {
            // logic from onClick override
          }
        });

  3. #3
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    Using a SelectHandler on the button is the correct way to have code executed when the button is clicked and when the overflow mene item is clicked.

    The overflow translates buttons to menu items and uses the SelectHandler from the button with the mene item. The button onClick method will not be called when the button is part of the overflow menu.

Thread Participants: 2