GXT KeyListener.componentKeyDown()立即关闭MessageBox.alert() [英] GXT KeyListener.componentKeyDown() immediately closes MessageBox.alert()
问题描述
在GXT中,MessageBox
方法是异步的,这意味着在显示消息框时应用程序不会锁定".
In GXT, MessageBox
methods are asynchronous, meaning that the application does not "lock up" while the message box is displayed.
我使用KeyListener
处理表单中的Enter键(以提高可用性,即允许使用Enter键提交表单),随后在应用程序处理用户凭据时禁用表单字段.如果它们不正确,则显示MessageBox.alert()
,然后重新启用表单字段.但是,由于alert()
立即返回,因此表单字段立即又变得可用,从而允许用户在不关闭警报的情况下输入数据.
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.
解决方案是在alert()
中使用回调.但是,按Enter键不仅会导致提交表单,还会使警报立即消失(就像表单和消息框都在处理回车键一样).在用户再次按下Enter键或单击确定"按钮之前,如何保持警报框打开?
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?