diff browser_side/register.py @ 237:531b8809d1ab

browser_side: fixed browser built-in auto-completion in login/register panels
author souliane <souliane@mailoo.org>
date Thu, 10 Oct 2013 18:29:07 +0200
parents 759fd7386e1e
children c24715dcd2f6
line wrap: on
line diff
--- a/browser_side/register.py	Thu Nov 07 15:22:28 2013 +0100
+++ b/browser_side/register.py	Thu Oct 10 18:29:07 2013 +0200
@@ -39,6 +39,7 @@
 from pyjamas import Window
 from pyjamas.ui.KeyboardListener import KEY_ESCAPE, KEY_ENTER
 import re
+from pyjamas.Timer import Timer
 
 
 class RegisterPanel(FormPanel):
@@ -154,14 +155,18 @@
 
     def onKeyPress(self, sender, keycode, modifiers):
         if keycode == KEY_ENTER:
+            # Browsers offer an auto-completion feature to any
+            # text box, but the selected value is not set when
+            # the widget looses the focus. Using a timer with
+            # any delay value > 0 would do the trick.
             if sender == self.login_box:
-                self.login_pass_box.setFocus(True)
+                Timer(10, lambda: self.login_pass_box.setFocus(True))
             elif sender == self.login_pass_box:
                 self.onLogin(None)
             elif sender == self.register_login_box:
-                self.email_box.setFocus(True)
+                Timer(10, lambda: self.email_box.setFocus(True))
             elif sender == self.email_box:
-                self.register_pass_box.setFocus(True)
+                Timer(10, lambda: self.register_pass_box.setFocus(True))
             elif sender == self.register_pass_box:
                 self.onRegister(None)