代号一个stop()方法:为什么不保留Dialog? [英] Codename One stop() method: why don't we keep Dialog?

查看:37
本文介绍了代号一个stop()方法:为什么不保留Dialog?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认代号一种方法是:

public void stop() {
        current = getCurrentForm();
        if (current instanceof Dialog) {
            ((Dialog) current).dispose();
            current = getCurrentForm();
        }
    }

是否真的需要设置对话框?为什么?
消除Dialog相关代码的优缺点?

Is it really necessary to dispose a Dialog? Why? Advantages and disadvantages of eliminating the Dialog related code?

推荐答案

start()被调用来恢复应用程序。因此,如果最小化,将调用 stop()并放置对话框。假设它没有执行此操作... start()将再次被调用,对话框将再次显示。

start() is invoked to restore the app. So if it's minimized stop() will be invoked and dispose the dialog. Let's say it doesn't do that... start() will be invoked again and dialog will be shown again.

show()对话框的方法被阻止。因此,它将停止当前的回调,并有效地破坏了整个还原过程。

The show() method of dialog is blocking. So it will stop the current callback in its tracks and effectively botch the whole restore process.

作为替代方案,我们在过去尝试过检查是否是还原对话框,并使用 showModless(),但这在某些端口代码上也存在问题,这些代码还会在当前上调用 show()表格。唯一可行的解​​决方案是将对话框实例另存为特殊情况并进行处理。然后在 start()中使用 callSerially()重新显示它。

As an alternative we tried in the past to check if this is a dialog on restore and use showModless() but this has issues with some port code that also invokes show() on the current Form. The only solution that might work is to save the dialog instance as a special case and dispose it. Then re-show it with a callSerially() in start().

这篇关于代号一个stop()方法:为什么不保留Dialog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆