本文介绍了ExtJS 4“永远在最前面"窗户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现可以始终位于顶部的 Window.我该怎么做?我对 WindowManager 的所有尝试都没有给我任何结果:(

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 :(

推荐答案

在 Ext.window.Window 中,有一个名为modal"的属性:将其设置为 true.

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

否则,请使用 WindowManager 来管理您的窗口:在这种情况下,您必须按照以下步骤操作:

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

  1. 注册您的窗口到 WindowManager (Ext.WindowManager.register (winId))
  2. 使用 bringToFront 方法将窗口设置在顶部 (Ext.WindowManager.bringToFront (winId))
  3. 最后,使用getActive方法(Ext.WindowManager.getActive())检查顶部的元素
  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 ())

例如:

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

或者:

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

希望对你有帮助.

Cyaz

这篇关于ExtJS 4“永远在最前面"窗户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 11:57