PDA

View Full Version : How can I know which window is on front?



Elfayer
6 Aug 2012, 2:04 AM
Hi,

I'm looking for something like "window.isOnFront() == true". Which doesn't exist.. =/

Is there something similar that can tell me if the window is on front or not?

friend
6 Aug 2012, 5:44 AM
If nothing else, you can compare the Window's zindex to some other component to determine if it's 'on top':



if (window1.getEl().zindex > someOtherComponent.getEl().zindex) {
// do something.
}

Elfayer
6 Aug 2012, 6:33 AM
I'm doing a web desktop, so I can open multiple windows.
With the ZIndex, can I know easily which of the windows is on front (if there is one), or must I test each against each ?

droessner
6 Aug 2012, 7:43 AM
Take a look at Ext.WindowManager. Ext.WindowManager.getActive() should give you what you are looking for.

sword-it
7 Aug 2012, 12:12 AM
Hi!
i guess you have to first register your windows in WindowManager before using getActive() method of it.

Sample:-



var win1 = Ext.create ('Ext.window.Window', {
title: 'First window' ,
id:'first',
..
});

var win2 = Ext.create ('Ext.window.Window', {
title: 'Second window' ,
id:'second',
..
});



// Register your windows to the WindowManager
Ext.WindowManager.register (win1);
Ext.WindowManager.register (win2);




alert (Ext.WindowManager.getActive().getId ());

droessner
7 Aug 2012, 4:31 AM
I don't think you need to manually register the windows. See the API for http://docs.sencha.com/ext-js/4-1/#!/api/Ext.WindowManager-method-register

"Registers a floating Ext.Component with this ZIndexManager. This should not need to be called under normal circumstances. Floating Components (such as Windows, BoundLists and Menus) are automatically registered with a zIndexManager at render time."