extjs 启用按钮时不显示工具提示

js5cn81o  于 2022-11-05  发布在  其他
关注(0)|答案(2)|浏览(136)

从Ext5升级到7.2后,以编程方式启用按钮后,将无法再看到工具提示。

Ext.define('X', {
extend: 'Ext.panel.Panel',

initComponent: function() {
    this.tbar = [{
        text: 'Foo',
        disabled: true,
        itemId: 'fooBtn',
        tooltip: 'FooTip',
        handler: function(btn){
            this.setHtml('Test')
        },
        scope: this
    },
    {
        text: 'Bar',
        tooltip: 'BarTip',
        handler: function(btn) {
            this.down('#fooBtn').enable();
        },
        scope: this
    }];
    this.callParent();
}
});

Ext.application({
name: 'Fiddle',

launch: function() {
    new X({
        renderTo: document.body,
        title: 'Foo',
        width: 200,
        height: 200
    });
 }
});

https://fiddle.sencha.com/#view/editor&fiddle/37o5

aurhwmvo

aurhwmvo1#

奇怪的错误。您可以使用下列覆写来修正它:

Ext.define('overrides.button.Button', {
    override: 'Ext.button.Button',

    setTooltip: function(tooltip, initial) {
        var me = this,
            targetEl = me.el;

        if (me.rendered) {
            if (!initial || !tooltip) {
                me.clearTip();
            }

            if (tooltip) {
                if (Ext.quickTipsActive && Ext.isObject(tooltip)) {
                    Ext.tip.QuickTipManager.register(Ext.apply({
                        target: targetEl.id
                    }, tooltip));

                    me.tooltip = tooltip;
                }
                else {
                    targetEl.dom.setAttribute(me.getTipAttr(), tooltip);
                }

                me.currentTooltipEl = targetEl;
            }
        }
        else {
            me.tooltip = tooltip;
        }

        return me;
    }
});
vawmfj5a

vawmfj5a2#

您可以尝试在启用以下功能后添加一行:

handler: function(btn) {
            this.down('#fooBtn').enable();
  ******this.down('#fooBtn').setTooltip("FooTip");*****
        },

可能是一个坏的解决方案,但需要更少的代码。

相关问题