GXT KeyListener.componentKeyDown() 立即关闭 MessageBox.alert()
在 GXT 中,MessageBox
方法是异步的,这意味着应用程序在显示消息框时不会“锁定”。
我使用 KeyListener
处理表单中的输入按键(以提高可用性,即允许通过输入键提交表单),然后在应用程序处理用户凭据时禁用表单字段。 如果它们不正确,我会显示 MessageBox.alert()
,然后重新启用表单字段。 但是,由于 alert()
立即返回,因此表单字段立即再次可用,从而允许用户在不关闭警报的情况下输入数据。
解决方案是在 alert()
中使用回调; 但是,按 Enter 按键不仅会导致表单提交,还会导致警报立即消失(就好像表单和消息框都在处理 Enter 键一样)。 如何保持警报框打开,直到用户再次按 Enter 键或单击“确定”按钮?
In GXT, MessageBox
methods are asynchronous, meaning that the application does not "lock up" while the message box is displayed.
I using a KeyListener
to process enter key presses in a form (to increase usability, i.e., allowing the form to be submitted by the enter key) and subsequently disabling the form fields while the application processes the user's credentials. If they are incorrect, I show a MessageBox.alert()
and then re-enable the form fields. However, since alert()
returns immediately, the form fields are immediately made available again, allowing the user to input data without closing the alert.
The solution is to use a callback in alert()
; however, the enter keypress not only causes the form to submit, but also causes the alert to immediately dismiss (as if both the form and the message box are processing the enter key). How do I keep the alert box open until the user presses enter a second time or clicks the "Ok" button?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关键是 GWT:
The key is
DeferredCommand
provided by GWT: