我要做的是为您的桌面创建一个面板子类,并为您的窗口创建一个窗口子类。将“windowOpened”侦听器添加到您的自定义面板,并从您的自定义窗口的“显示”侦听器中触发此事件。
像这样的东西:
桌面面板.js
Ext.define('App.view.DesktopPanel', {
extend: 'Ext.panel.Panel',
alias: 'widget.desktoppanel',
initComponent: function() {
this.callParent();
this.addListener('windowOpened', function(newWindow){
//Do whatever it is you want to do here
});
}
});
桌面窗口.js
Ext.define('App.view.DesktopWindow', {
extend: 'Ext.window.Window',
alias: 'widget.desktopwindow',
constrain: true,
initComponent: function() {
this.renderTo = this.ownerPanel.getLayout().getTarget();
this.callParent();
this.addListener('show', function(){
this.ownerPanel.fireEvent('windowOpened',this);
});
}
});
那么你的代码将是这样的:
var win = Ext.create('App.view.DesktopWindow', {
ownerPanel: MyDesktop, //an instance of 'DesktopPanel'
});
win.show();