Announcement

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

    Menu's showIcons seems to not behave as documented

    SmartClient Version: v9.1p_2016-04-15/Pro Development Only (built 2016-04-15)
    Google Chrome Version 43.0.2357.125 unknown (64-bit) (any browser)

    When looking at the documentation for isc.Menu's showIcons: http://www.smartclient.com/docs/9.1/...Menu.showIcons, it states that when unset, the icon column will appear if one of the items have an icon, etc. checked. In my case below, I do not set showIcons and have no icons specified in the menu items. The expected result should hide the icon column on the left of the menu. But this does not happen. Am I doing this wrong or missing a configuration property?

    Code:
    isc.Menu.create({
        ID: "menu",
        autoDraw: false,
        showShadow: true,
        shadowDepth: 10,
        data: [
            {title: "New"},
            {title: "Open"}
        ]
    });
    
    var menuButton = isc.MenuButton.create({
        ID: "menuButton",
        autoDraw: false,
        title: "File",
        width: 100,
        menu: menu
    });
    
    isc.HStack.create({
        width: "100%",
        members: [menuButton]
    });

    #2
    We have tracked this down, and it turns out to be a documentation error. The property was not actually designed to work as stated in the docs since it would give menus inconsistent appearance in a way that would seem random to the user. A miscommunication caused the documentation to be written incorrectly. We will correct the docs to reflect actual behavior.

    Comment


      #3
      Thanks for letting us know! Would it be possible to design our menu as incorrectly stated in the menu? We would like to remove the icon column for some rows that do not have an icon.

      Comment


        #4
        Can you clarify: you want to remove the icon column automatically if ALL rows have no icon, right?

        If so, you could do that by iterating over your items before you apply them to the menu - if any item has an icon specified, set showIcons before construction.

        You could also do this automatically after construction - one way would be with an override of draw(), something like this:

        Code:
            draw : function () {
                var returnVal = this.Super("draw", arguments);
                
                // get an array of icon values from the items
                var icons = this.data.getProperty("icon");
                if (icons) icons.removeEmpty();
        
                if (icons && icons.length > 0) {
                    if (!this.showIcons) this.setShowIcons(true);
                } else {
                    if (this.showIcons) this.setShowIcons(false);
                }
               
                return returnVal;
            }

        Comment


          #5
          That is a great idea, thank you very much! To clarify, would it be possible to remove the icon column for a SPECIFIC row if that row does not have an icon? Both ways work for us but it would be ideal for us to remove icon columns specifically for a row if it does not have an icon, while other rows could have an icon column.
          Last edited by shresthg_des; 13 Jul 2016, 08:08.

          Comment


            #6
            No, that's not possible - and wouldn't be desirable since the various menu item titles would then be misaligned.

            Comment

            Working...
            X