如何管理外部应用程序中的窗口

发布于 2025-01-03 15:29:00 字数 1354 浏览 1 评论 0原文

我有 2 个 AIR 应用程序(AB),它们能够通过 LocalConnection 对象进行通信。我已经验证消息肯定是正确发送/接收的。

我希望能够让 A 告诉 B 来到前面。这两个应用程序都是全屏的:

stage.fullScreenSourceRect = new Rectangle(0, 0, 1080, 1920);
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

我已经尝试了几种排列,但到目前为止似乎没有任何效果。

private function initSlave(channel: String): void {
    conn = new LocalConnection();
    conn.client = {
        'activateSlave': activateSlave
    };
    conn.allowDomain("*");
    conn.connect("_" + channel);
}

private function activateSlave(): void {
    stage.nativeWindow.orderToFront();

    // or

    stage.nativeWindow.activate();

    // or

    stage.nativeWindow.alwaysInFront = true;
    stage.nativeWindow.alwaysInFront = false;
}

如果我将两个应用程序都保持在窗口模式 (stage.displayState = StageDisplayState.NORMAL),则切换 alwaysInFront 实际上有效。调用 activate()orderToFront() 仍然没有任何作用。如果我尝试切换 alwaysInFront 然后将应用程序设置为全屏,则应用程序最终会在窗口应用程序后面全屏显示。也许在将应用程序设置为全屏之前我应该​​等待一个事件?

我发现一个线程提到 orderToFront() 仅适用于同一应用程序中的窗口,这解释了为什么它似乎没有做任何事情。

有谁对实现这一目标有任何见解吗?也许有一种方法可以让我将 B 嵌入到应用程序 A 中,这样它们实际上是同一个应用程序?由于需要外部资源,我不确定如何使用 AIR 应用程序执行此操作,就像加载 SWF 一样简单。

I have 2 AIR applications (A and B) that are able to communicate via a LocalConnection object. I've verified that messages are definitely being sent/received appropriately.

I want to be able to have A tell B to come to the front. Both applications are full screen:

stage.fullScreenSourceRect = new Rectangle(0, 0, 1080, 1920);
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

I've tried several permutations, but as of yet nothing seems to work.

private function initSlave(channel: String): void {
    conn = new LocalConnection();
    conn.client = {
        'activateSlave': activateSlave
    };
    conn.allowDomain("*");
    conn.connect("_" + channel);
}

private function activateSlave(): void {
    stage.nativeWindow.orderToFront();

    // or

    stage.nativeWindow.activate();

    // or

    stage.nativeWindow.alwaysInFront = true;
    stage.nativeWindow.alwaysInFront = false;
}

If I leave both applications in windowed mode (stage.displayState = StageDisplayState.NORMAL), then toggling alwaysInFront actually works. Calling activate() or orderToFront() still do nothing. If I try to toggle alwaysInFront and then set the application to fullscreen, the application ends up fullscreen behind my windowed app. Maybe there is an event I should wait for before setting the app to fullscreen?

I found a thread mentioning that orderToFront() only works relative to windows within the same application, which explains why it doesn't seem to do anything.

Does anyone have any insights into pulling this off? Maybe there is a way for me to embed B into application A so they are actually the same application? I am not sure how to do this with an AIR application as simply as just loading the SWF due to requiring external resources.

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

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

发布评论

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

评论(1

过潦 2025-01-10 15:29:00

由于没有其他人提供解决方案,我将快速提及我正在使用的黑客技术。基本上我有 2 个 LocalConnection 通道,一个从 AB,一个从 BA
然后,可见程序(例如A)将淡出为白色,将visible设置为false,并向B发送消息代码>放弃控制权。 B 已使用 stage.nativeWindow.visible = false 初始化自身,当它收到来自 A 的消息时,它会显示为全白屏幕并在 GUI 中淡出。在Avisible设置为false之前有一个轻微的偏移,以便给B时间显示,否则有一个当两个窗口都最小化时会弹出。

无论如何,就这样,它很丑,但实际上效果相当好。

As no one else has offered a solution, I'll just mention quickly the hack that I'm using. Basically I have 2 LocalConnection channels, one from A to B, and one from B to A.
The visible program (e.g. A) will then fade to white, set visible to false, and send a message to B giving up control. B has initialized itself with stage.nativeWindow.visible = false, and when it receives the message from A it goes visible as a full white screen and fades in the GUI. There is a slight offset before A sets visible to false to give B time to display, otherwise there is a pop in the brief moment when both windows are minimized.

Anyway, there you go, it's ugly but it actually works fairly well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文