comparison 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
comparison
equal deleted inserted replaced
236:9b078380dacf 237:531b8809d1ab
37 from pyjamas.ui.Image import Image 37 from pyjamas.ui.Image import Image
38 from pyjamas.ui.Hidden import Hidden 38 from pyjamas.ui.Hidden import Hidden
39 from pyjamas import Window 39 from pyjamas import Window
40 from pyjamas.ui.KeyboardListener import KEY_ESCAPE, KEY_ENTER 40 from pyjamas.ui.KeyboardListener import KEY_ESCAPE, KEY_ENTER
41 import re 41 import re
42 from pyjamas.Timer import Timer
42 43
43 44
44 class RegisterPanel(FormPanel): 45 class RegisterPanel(FormPanel):
45 46
46 def __init__(self, callback): 47 def __init__(self, callback):
152 elif tabIndex == 1: 153 elif tabIndex == 1:
153 self.register_login_box.setFocus(True) 154 self.register_login_box.setFocus(True)
154 155
155 def onKeyPress(self, sender, keycode, modifiers): 156 def onKeyPress(self, sender, keycode, modifiers):
156 if keycode == KEY_ENTER: 157 if keycode == KEY_ENTER:
158 # Browsers offer an auto-completion feature to any
159 # text box, but the selected value is not set when
160 # the widget looses the focus. Using a timer with
161 # any delay value > 0 would do the trick.
157 if sender == self.login_box: 162 if sender == self.login_box:
158 self.login_pass_box.setFocus(True) 163 Timer(10, lambda: self.login_pass_box.setFocus(True))
159 elif sender == self.login_pass_box: 164 elif sender == self.login_pass_box:
160 self.onLogin(None) 165 self.onLogin(None)
161 elif sender == self.register_login_box: 166 elif sender == self.register_login_box:
162 self.email_box.setFocus(True) 167 Timer(10, lambda: self.email_box.setFocus(True))
163 elif sender == self.email_box: 168 elif sender == self.email_box:
164 self.register_pass_box.setFocus(True) 169 Timer(10, lambda: self.register_pass_box.setFocus(True))
165 elif sender == self.register_pass_box: 170 elif sender == self.register_pass_box:
166 self.onRegister(None) 171 self.onRegister(None)
167 172
168 def onKeyUp(self, sender, keycode, modifiers): 173 def onKeyUp(self, sender, keycode, modifiers):
169 pass 174 pass