调整窗口大小时收到通知的正确方法是什么?
我有一个应用程序,将多个 Windows 放置在 com.extjs.gxt.desktop.client.Desktop 中。我需要附加一个侦听器,它在调整大小时记录每个窗口的大小。我看到两个问题:
虽然调整窗口大小时会触发移动事件,但它们似乎是在新大小实际应用于窗口之前触发的,因此我无法直接从窗口请求新大小。< /p>
无论窗口的实际大小如何,我在侦听器中收到的 WindowEvent 包含的大小为 0x0。
我在这里缺少什么吗?
这是我的附加代码:
protected void addWindowListeners( Window w,
String uid, WindowData windowData )
{
WindowChangeListener l = new WindowChangeListener( uid, windowData );
w.addWindowListener( l );
// Add this again since the default WindowListener doesn't support the Move event.
w.addListener( Events.Move, l );
}
和侦听器类:
protected class WindowChangeListener
extends WindowListener
implements Listener<WindowEvent>
{
@Override
public void windowHide( WindowEvent we )
{
updateWindowData( we );
}
@Override
public void windowShow( WindowEvent we )
{
updateWindowData( we );
}
public void windowMove( WindowEvent we )
{
updateWindowData( we );
}
protected void updateWindowData( WindowEvent we )
{
// Here's the part that needs to get notified with the new size.
}
@Override
public void handleEvent( WindowEvent we )
{
if( we.getType() == Events.Move )
windowMove( we );
else
super.handleEvent( we );
}
}
感谢任何人的见解。我觉得我必须错过一些简单的东西。
I have an application that places several Windows within a com.extjs.gxt.desktop.client.Desktop. I need to attach a listener which records the size of each window when it is resized. I'm seeing two issues:
While Move Events are fired when the window is resized, they appear to be fired BEFORE the new size is actually applied to the window, so I cannot request the new size from the window directly.
The WindowEvent I receive in my Listener contains a size of 0x0, regardless of the actual size of the window.
Is there something I'm missing here?
Here's my attach code:
protected void addWindowListeners( Window w,
String uid, WindowData windowData )
{
WindowChangeListener l = new WindowChangeListener( uid, windowData );
w.addWindowListener( l );
// Add this again since the default WindowListener doesn't support the Move event.
w.addListener( Events.Move, l );
}
And the listener class:
protected class WindowChangeListener
extends WindowListener
implements Listener<WindowEvent>
{
@Override
public void windowHide( WindowEvent we )
{
updateWindowData( we );
}
@Override
public void windowShow( WindowEvent we )
{
updateWindowData( we );
}
public void windowMove( WindowEvent we )
{
updateWindowData( we );
}
protected void updateWindowData( WindowEvent we )
{
// Here's the part that needs to get notified with the new size.
}
@Override
public void handleEvent( WindowEvent we )
{
if( we.getType() == Events.Move )
windowMove( we );
else
super.handleEvent( we );
}
}
Thanks for any insight anyone has. I feel like I've got to be missing something simple.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,我在 Sencha 论坛上获得了魔法:http://www.sencha.com/forum/showthread.php?121249-What-s-the- right-way-to-be-notified-when-a-Window-is-resized&p=561340&posted=1#post561340
结果我可以监听 Window 上的调整大小事件:
I actually was given the magic on the Sencha forums: http://www.sencha.com/forum/showthread.php?121249-What-s-the-right-way-to-be-notified-when-a-Window-is-resized&p=561340&posted=1#post561340
Turns out that I can listen for a resize event on Window: