Announcement

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

  • Put button into menu and put menu into IMenuButton

    Hi guys,

    I realize that there are too many buttons on the page.

    So I write the following logic and I try to hide some button inside the IMenuButton. However, when I click on the IMenuButton, no button has been shown.

    May somebody can help with this issue? Thankssssss.

    here is my code:

    // buttonLayout is a HLayout and it has around 10 button members.

    IMenuButton btnMenu = null;
    if (buttonLayout.getMembersLength()>5) {

    int lastIndex = buttonLayout.getMembersLength()-1;

    Menu menu = new Menu();

    for(int i = 4; lastIndex > i; lastIndex--) {

    GWT.log("lastIndex : "+lastIndex);

    IButton temp = new IButton();
    temp = (IButton) buttonLayout.getMember(lastIndex);

    GWT.log("temp "+temp);
    GWT.log("buttonlayout "+buttonLayout.getMember(lastIndex));

    menu.addMember(temp);
    buttonLayout.removeMember(buttonLayout.getMember(lastIndex));

    }

    GWT.log("menu size : "+menu.getMembersLength());

    btnMenu = new IMenuButton("More Buttons", menu);
    buttonLayout.addMember(btnMenu);

    }

    Click image for larger version

Name:	myWYO.png
Views:	1
Size:	4.3 KB
ID:	256445
    Click image for larger version

Name:	l7fY9.png
Views:	1
Size:	6.8 KB
ID:	256446

  • #2
    This approach is wrong - you aren't setting data on the menu - see this sample for the proper technique.

    Comment


    • #3
      Originally posted by Isomorphic View Post
      This approach is wrong - you aren't setting data on the menu - see this sample for the proper technique.
      many thanks with your help! The problem has been solved.

      new code :
      for(int i = 4; lastIndex > i; lastIndex--) {

      HStack editButtons = new HStack(1);
      editButtons.setDefaultLayoutAlign(VerticalAlignment.CENTER);
      editButtons.setSnapTo("TR");
      editButtons.setHeight("100%");
      editButtons.setMembers(buttonLayout.getMember(lastIndex));

      MenuItem editMenuItem = new MenuItem("");
      editMenuItem.setShowRollOver(false);
      editMenuItem.setEmbeddedComponent(editButtons);

      menu.addItem(editMenuItem);
      buttonLayout.removeMember(buttonLayout.getMember(lastIndex));

      }

      Comment


      • #4
        Originally posted by Isomorphic View Post
        This approach is wrong - you aren't setting data on the menu - see this sample for the proper technique.
        May I know how to remove the background of the menu?

        When I click "More Buttons", a menu has been shown with white background.
        Click image for larger version

Name:	MenuBg.png
Views:	1
Size:	8.5 KB
ID:	256451

        I try the following code but none of them work.

        menu.setShowEdges(false);
        menu.setBackgroundColor("rgba(0,0,0,0)");
        menu.setBackgroundColor("transparent");

        And it looks like all the showcase of menu are with white background color.

        Thanks for your help!

        Comment

        Working...
        X