我會做的是爲您的桌面創建panel的子類,併爲您的窗口創建子類window。將「windowOpened」偵聽器添加到自定義面板,並從您的自定義窗口的「顯示」偵聽器中觸發此事件。
事情是這樣的:
DesktopPanel.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
});
}
});
DesktopWindow.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();
我做了類似的事,謝謝! – codemonkeyww 2013-02-22 14:59:59