ExtJS Window setActive() 无法按预期工作

ExtJS Window setActive() not working as expected

本文关键字:工作 Window setActive ExtJS      更新时间:2023-09-26

TL/DR:

调用 window.setActive(false) 不会将窗口的 active 属性设置为 false

完整详情:

我有以下 ExtJS 类继承自Ext.window.Window

Ext.define('WD.view.TbWindow', {
    extend : 'Ext.window.Window',
    isTbWindow: true,
    title: 'Set Me!!',
    constrain: true, // constrain window to viewport
    autoShow: false,
    maximizable: true,
    minimizable: true,
    renderTo: 'main_panel-body',
    minimize: function() {
        this.hide();
        this.setActive(false);
        this.animateTarget.handleWinMinimize();
    },
    ...
});

在上面的函数minimize中,有调用this.setActive(false);

我使用 Chrome 开发者工具来调试代码。在执行行之前this.active true。行执行后,它仍然true。我正在使用 ExtJS 4.1。

源代码中没有将活动属性设置为 true 或 false,文档中也没有提及。

setActive: function(active, newActive) {
    var me = this;
    if (active) {
        if (me.el.shadow && !me.maximized) {
            me.el.enableShadow(true);
        }
        if (me.modal && !me.preventFocusOnActivate) {
            me.focus(false, true);
        }
        me.fireEvent('activate', me);
    } else {
        // Only the *Windows* in a zIndex stack share a shadow. All other types of floaters
        // can keep their shadows all the time
        if (me.isWindow && (newActive && newActive.isWindow)) {
            me.el.disableShadow();
        }
        me.fireEvent('deactivate', me);
    }
}

问题出在Ext.WindowManager.getActive()方法上。事实上,在Web桌面示例中,Sencha的家伙实际上做了一些不太好的编码来获得实际的活动窗口。我复制了该代码,并开始在我的代码中支持 Windows 数组,这解决了我的问题。

我已经编写了一个(并在其中构建了额外的功能)一个继承自Ext.util.MixedCollectionDesktopMgr小部件,并充当"桌面管理器",其中"桌面"意味着任何旨在处理多个窗口、激活、停用、导航到上一个/下一个等的 ExtJS 容器。

您可以从此要点下载并使用DesktopMgr。如果您找到改进它的方法(或要修复的错误!