Announcement

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

  • claudiobosticco
    replied
    Originally posted by claudiobosticco View Post
    and obviously the same question applies to other handlers (dynamicIcon/Title, enableIf).
    actually those won't be called when the item is a ToolStripButton.

    But if I add a getTitle to the AdaptiveMenu item it won't be called neither. Here is a test case:

    Code:
    // variable-length name label and button control
    isc.Label.create({
        ID: "nameLabel",
        width: 1,
        wrap: false,
        refreshTitle : function (longName) {
            var name = longName ? "Alejandro O'Reilly" : "Lucy Lu";
            this.setContents("<b>Candidate: " + name + "</b>");
        }
    });
    
    isc.AdaptiveMenu.create({
        ID: "adaptiveMenu",
        defaultLayoutAlign: "center",
        height:30,
        items: [
            {title: "Contact", click: "isc.say(this.title)",
                    dynamicTitle: function (target, menu, item) {
                        return "dynamic title";
                    },
                    getTitle: function (target, menu, item) {
                        return "get title";
                    }
            },
            {title: "Hire Now", click: "isc.say(this.title)"},
            {title: "View Résumé", click: "isc.say(this.title)"},
            {
                title: "Edit",
                showRollOver: false,
                embeddedComponent: isc.HStack.create({
                    snapTo: "TR",
                    height: "100%",
                    width: 190,
                    membersMargin: 3,
                    layoutMarginBottom: 5,
                    defaultLayoutAlign: "center",
                    members: [
                        isc.IButton.create({title: "Cut", autoFit:true, click: "isc.say(this.title)"}),
                        isc.IButton.create({title: "Copy", autoFit:true, click: "isc.say(this.title)"}),
                        isc.IButton.create({title: "Paste", autoFit:true, click: "isc.say(this.title)"})
                    ]
                }),
                embeddedComponentFields: ["key"]
            }
        ],
        menuProperties: {
            width: 350
        }
    });
    
    isc.Button.create({
        top: 50,
        refreshTitle : function (longName) {
            nameLabel.refreshTitle(longName);
            this.setTitle(longName ? "Shorter Name" : "Longer Name");
        },
        click : function () {
            this.longTitle = !this.longTitle;
            this.refreshTitle(this.longTitle);
        },
        initWidget : function () {
            this.Super("initWidget", arguments);
            this.refreshTitle();
        }
    });
    
    // parent Layouts
    isc.ToolStrip.create({
        width: 375,
        membersMargin: 5,
        layoutLeftMargin: 10,
        ID: "toolStrip",
        showResizeBar: true,height:40,
        members: [nameLabel, "separator", adaptiveMenu]
    });
    
    isc.HLayout.create({
        height:40,
        width: "100%",
        hPolicy: "none",
        members: [toolStrip]
    });
    Last edited by claudiobosticco; 22 Jul 2024, 23:47.

    Leave a comment:


  • claudiobosticco
    replied
    and obviously the same question applies to other handlers (dynamicIcon/Title, enableIf).

    Instead, I don't expect differences for visible/enableWhen, right?

    Leave a comment:


  • claudiobosticco
    started a topic AdaptiveMenu items

    AdaptiveMenu items

    Hello, I've recently started using the AdaptiveMenu (which is a cool component BTW), and I just realized the menuItem.click handler is actually different in its arguments when an item is actually a menuItem vs when it's rendered as a ToolStripButton.

    Is it actually intended to work this way?
    So that, if I need a reference to the menu object, I must write code like this:

    Code:
    click: function(target, item, menu) {
        let theMenu = menu ? menu.creator : this.getParentCanvas();
        isc.logEcho(theMenu);
    }
Working...
X