From da870ca15cdd2c48bf4ef1af21fae16b96a862ce Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Tue, 17 Apr 2012 14:26:42 +0800 Subject: [PATCH] fix bug in showInfoMsgWithDelay() The release key event will cause the dialog disappear immediately after show up. Also the timeout error is handled with pcall. --- dialog.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dialog.lua b/dialog.lua index 9c3de5b48..6f0b3850f 100644 --- a/dialog.lua +++ b/dialog.lua @@ -41,7 +41,17 @@ function showInfoMsgWithDelay(text, msec, refresh_mode) InfoMessage:show(text) fb:refresh(refresh_mode) -- util.usleep(msec*1000) - input.waitForEvent(msec*1000) + + -- eat the first key release event + local ev = input.waitForEvent() + adjustKeyEvents(ev) + repeat + ok = pcall( function() + ev = input.waitForEvent(msec*1000) + adjustKeyEvents(ev) + end) + print(is_not_timeout) + until not ok or ev.value == EVENT_VALUE_KEY_PRESS Screen:restoreFromSavedBB() fb:refresh(refresh_mode)