Flex 4:标题窗口超出可访问区域

发布于 2024-11-18 08:03:07 字数 239 浏览 1 评论 0原文

我有一个奇怪的问题 - 我使用标题窗口来创建给用户的消息。用户可以在屏幕上移动标题窗口,以便主屏幕可见。

但是,如果用户将标题窗口移动太多,它实际上可能会超出浏览器可访问区域 - 用户别无选择,只能关闭浏览器并重新开始。我们如何确保标题窗口的移动受到限制,以便标题栏始终可供控制?

我的措辞可能不对 - 请检查所附图片图像超出屏幕

I have a strange issue- I use a title window to create a message to the user. The user has the ability to move the title window around the screen so that the main screen is visible.

However if the user were to move the title window way too much, it can actually go outside the browser accessible area- the user has no option but to close the browser and start again. How do we ensure that the title window movement is limited, such that the title bar is always available for control?

I might not have worded this right- pls check the attached imageimage going out of screen.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

以往的大感动 2024-11-25 08:03:07

我会听 move TitleWindow 的 事件。如果窗口移出应用程序的可见坐标,请将其移回来。

如果您唯一的问题是允许用户关闭窗口,那么除了顶部的“x”之外,您还可以在窗口底部添加一个“关闭”按钮。

I'd listen to the move event of the TitleWindow. If the window is moved out of the visible coordinates of the application, move it back.

If you're only issue is w/ allowing the users to closet the window, then you could add a "Close" button on the bottom of the window in addition to the 'x' at the top.

手长情犹 2024-11-25 08:03:07

如果您可以使用自定义组件,我建议您重写 TitleWindow 的 move() 方法。我使用以下代码来限制窗口移动:

public class PopUpWindow extends TitleWindow
{
    private static const MIN_VISIBLE:int = 50;

    public override function move(x:Number, y:Number):void
    {
        var maxX:Number = stage.stageWidth - MIN_VISIBLE;
        var maxY:Number = stage.stageHeight - MIN_VISIBLE;

        if (x < 0)
            x = 0;
        else if (x > maxX)
            x = maxX;

        if (y < 0)
            y = 0;
        else if (y > maxY)
            y = maxY;

        super.move(x, y);
    }
}

If you can use a custom component I'd suggest you override the TitleWindow's move() method. I'm using the following code to restrict the window movement:

public class PopUpWindow extends TitleWindow
{
    private static const MIN_VISIBLE:int = 50;

    public override function move(x:Number, y:Number):void
    {
        var maxX:Number = stage.stageWidth - MIN_VISIBLE;
        var maxY:Number = stage.stageHeight - MIN_VISIBLE;

        if (x < 0)
            x = 0;
        else if (x > maxX)
            x = maxX;

        if (y < 0)
            y = 0;
        else if (y > maxY)
            y = maxY;

        super.move(x, y);
    }
}
无敌元气妹 2024-11-25 08:03:07

该函数在 titlewindow 的移动事件上调用:

        protected function titlewindow1_moveHandler(event:MoveEvent):void
        {
            // TODO Auto-generated method stub
            var window:UIComponent = event.currentTarget as UIComponent;
            var application:UIComponent = FlexGlobals.topLevelApplication as UIComponent;
            var bounds:Rectangle = new Rectangle(0, 0, application.width, application.height);
            var windowBounds:Rectangle = window.getBounds(application);
            var x:Number;
            var y:Number;
            if (windowBounds.left <= bounds.left)
                x = bounds.left;
            else if (windowBounds.right >= bounds.right)
                x = bounds.right - window.width;
            else
                x = window.x;
            if (windowBounds.top <= bounds.top)
                y = bounds.top;
            else if (windowBounds.bottom >= bounds.bottom)
                y = bounds.bottom - window.height;
            else
                y = window.y;
            window.move(x, y);
        }

This function is called on move event of titlewindow:

        protected function titlewindow1_moveHandler(event:MoveEvent):void
        {
            // TODO Auto-generated method stub
            var window:UIComponent = event.currentTarget as UIComponent;
            var application:UIComponent = FlexGlobals.topLevelApplication as UIComponent;
            var bounds:Rectangle = new Rectangle(0, 0, application.width, application.height);
            var windowBounds:Rectangle = window.getBounds(application);
            var x:Number;
            var y:Number;
            if (windowBounds.left <= bounds.left)
                x = bounds.left;
            else if (windowBounds.right >= bounds.right)
                x = bounds.right - window.width;
            else
                x = window.x;
            if (windowBounds.top <= bounds.top)
                y = bounds.top;
            else if (windowBounds.bottom >= bounds.bottom)
                y = bounds.bottom - window.height;
            else
                y = window.y;
            window.move(x, y);
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文