8

I need to implement Window which can be always on top. How can I to do it? All my tries with WindowManager give me no results :(

Guy Fawkes
  • 2,313
  • 2
  • 22
  • 39

1 Answers1

8

In Ext.window.Window, there's a property called 'modal': set it to true.

Otherwise, use the WindowManager to manage your windows: in this case you have to follow the following steps:

  1. register your windows to the WindowManager (Ext.WindowManager.register (winId))
  2. use bringToFront method to set your window on top (Ext.WindowManager.bringToFront (winId))
  3. finally, check the element on top with the getActive method (Ext.WindowManager.getActive ())

E.g.:

Ext.create ('Ext.window.Window', {
  title: 'Your window' ,
  width: 300 ,
  height: 300 ,
  html: 'ciao ciao' ,
  modal: true
}).show ();

Or:

var win1 = Ext.create ('Ext.window.Window', {
  title: 'Your window' ,
  id: 'firstWin' ,
  width: 300 ,
  height: 300 ,
  html: 'ciao ciao' ,
});
win1.showAt (50, 50);

var win2 = Ext.create ('Ext.window.Window', {
  title: 'Your window' ,
  id: 'secondWin' ,
  width: 300 ,
  height: 300 ,
  html: 'I love pizza' ,
});
win2.showAt (60, 60);

// Register your floating objects (window in this case) to the WindowManager
Ext.WindowManager.register (win1);
Ext.WindowManager.register (win2);

// Bring 'firstWin' on top
Ext.WindowManager.bringToFront ('firstWin');

// Then, check the zIndexStack
alert (Ext.WindowManager.getActive().getId ()); // this is firstWin, the window with the highest zIndex

Hope this help you.

Cyaz

Wilk
  • 7,873
  • 9
  • 46
  • 70
  • That's nice, and the **main question** is: **HOW** to detect that new window is showed over the my window? – Guy Fawkes May 11 '12 at 08:45
  • Ah, now I got it ;) Well, first you have to register your windows to the WindowManager. Then, check the zIndexStack of the WindowManager ;) The first element of the stack is that with the highest zIndex. Ext.WindowManager.zIndexStack[0] is your solution but I think the same thing should be done by Ext.WindowManager.getActive() but in my experiments it doesn't work... Now look to my first answer with the entire solution: it's just edited ;) – Wilk May 11 '12 at 09:58
  • 1
    Ok, I just understood how to get the window with the highest zIndex through Ext.WindowManager.getActive(): instead of using toFront() method of each windows, you have to use Ext.WindowManager.bringToFront(id/object) and then check it with Ext.WindowManager.getActive() ;) Look to the edited solution. Ciao! – Wilk May 11 '12 at 10:07
  • `Ext.WindowManager.zIndexStack[0]` is the most bottom component. It is the last element of the array, which is given by `getActive()`. – kirilloid Jul 30 '12 at 08:26
  • this is bad onTop isn't the same that modal :D – rChavz Nov 10 '13 at 10:52