从工具栏项启用和禁用ExtJS工具提示

时间:2011-06-07 12:31:10

标签: extjs extjs3

在我的toolbar中,checkbox用于启用和停用tooltip。如果checkbox被选中,那么我应该启用tooltip并且如果没有则它正在工作,那么我应该禁用它也工作。停用tooltip后,点击toolbar时不会点击toolbar中的任何项目,然后启用它。

  

toogleTooltiphandler

checkbox
function toggleTooltip() {
    debugger;
    if (Ext.getCmp("msai_tool_tip").checked) {
        Ext.QuickTips.enable();
        while (!Ext.QuickTips.isEnabled())
            Ext.QuickTips.enable();
    } else {
        Ext.QuickTips.disable();
        while (Ext.QuickTips.isEnabled())
            Ext.QuickTips.disable();
    }
}

这是我的工具栏创建代码:

Ext.QuickTips.init();
var tb = new Ext.Toolbar({
    id: 'form_menu_bar',
    renderTo: Ext.get('newproducttitle').dom,
    items: [{
        tooltip: {
            text: "Click on this button to generate the template and save it in server.",
            title: "Save",
            xtype: "quicktip"
        },
        iconCls: 'msai_save_template',
        handler: generateTemplate

    }, {
        tooltip: {
            text: "Click on this button to generate the template.",
            title: "Save to clipboard",
            xtype: "quicktip"
        },
        iconCls: 'msai_save_clipboard',
        handler: generateTemplateClipboard
    }]
});

请提供一些解决方案,以便我不会显示tooltip,如果用户点击工具栏而不是任何项目。

1 个答案:

答案 0 :(得分:0)

请查看以下小提琴,查看工作示例: https://fiddle.sencha.com/#view/editor&fiddle/2c7k

代码段:

Ext.QuickTips.init();

var tb = new Ext.Toolbar({
        renderTo: document.body,
        width: 600,
        height: 100,
        items: [{
            // xtype: 'button', // default for Toolbars, same as 'tbbutton'
            text: 'Button',
            tooltip: 'button'
        }, {
            xtype: 'splitbutton', // same as 'tbsplitbutton'
            text: 'Split Button',
            tooltip: 'Split Button'
        }, {
            xtype: 'checkbox',
            boxLabel: 'enable tooltip',
            checked: true,
            listeners: {
                check: function (checkbox, newValue, oldValue) {
                    if (newValue) {
                        Ext.QuickTips.enable();
                    } else {
                        Ext.QuickTips.disable();
                    }
                }
            }
        }]
    });
相关问题