0

只需在工具栏小提琴中的 sencha fiddle 链接菜单按钮中复制并运行以下代码

当我在工具栏中有多个菜单按钮并单击任何一个按钮时,所有按钮悬停时都会显示其他按钮的菜单。我希望菜单仅在单击时显示,而不是在按钮焦点或悬停时显示。

Ext.application({

name: 'Fiddle',

launch: function() {
    Ext.create({
        xtype: 'toolbar',
        renderTo: Ext.getBody(),
        layout: 'vbox',
        padding: 20,
        containsFocus : false,
        defaults: {
            xtype: 'button',
            margin: '0 0 12 0'
        },

        items: [{
            xtype: 'splitbutton',
            text: 'Split Button',
            // click the "Split Button" text to have the click handled
            // by the configured 'handler' function
            handler: function () {
                Ext.Msg.alert('Split Button', 'Button body clicked');
            },
            // clicking on the menu arrow will show the split button menu
            menu: {
                plain: true,
                items: [{
                    text: 'Split Menu Item #1'
                }, {
                    text: 'Split Menu Item #2'
                }],
                listeners: {
                    click: function (menu, item) {
                        Ext.Msg.alert('Menu Button', item.text);
                    }
                }
            }
        } ,{

            // clicking anywhere on the button will show its configured menu
            text: 'Button with Menu',
            menu: {
                plain: true,
                items: [{
                    text: 'Menu Item #1'
                }, {
                    text: 'Menu Item #2'
                }],
                // the click event handler for all menu items
                listeners: {
                    click: function (menu, item) {
                        Ext.Msg.alert('Menu Button', item.text);
                    }
                }
            }

        }]
    });
}

});
4

0 回答 0