comparison src/browser/sat_browser/register.py @ 795:a6b39838353f

browser_side: inform the user that entering a full JID in the login box is only needed for external XMPP account
author souliane <souliane@mailoo.org>
date Tue, 08 Dec 2015 15:11:02 +0100
parents 249e49f56f67
children fad9c9f82ae3
comparison
equal deleted inserted replaced
794:6a2fd7807770 795:a6b39838353f
41 from pyjamas.Timer import Timer 41 from pyjamas.Timer import Timer
42 42
43 import re 43 import re
44 44
45 from constants import Const as C 45 from constants import Const as C
46
47
48 KEY_AROBASE = 81 # XXX: this is the keycode for onKeyUp, the one which works for onKeyPress is 64!
46 49
47 50
48 class RegisterPanel(FormPanel): 51 class RegisterPanel(FormPanel):
49 52
50 def __init__(self, callback): 53 def __init__(self, callback):
146 self.login_box.setFocus(True) 149 self.login_box.setFocus(True)
147 elif index == 1: 150 elif index == 1:
148 self.register_login_box.setFocus(True) 151 self.register_login_box.setFocus(True)
149 152
150 def onKeyPress(self, sender, keycode, modifiers): 153 def onKeyPress(self, sender, keycode, modifiers):
154 # XXX: this is triggered before the textbox value has changed
151 if keycode == KEY_ENTER: 155 if keycode == KEY_ENTER:
152 # Browsers offer an auto-completion feature to any 156 # Browsers offer an auto-completion feature to any
153 # text box, but the selected value is not set when 157 # text box, but the selected value is not set when
154 # the widget looses the focus. Using a timer with 158 # the widget looses the focus. Using a timer with
155 # any delay value > 0 would do the trick. 159 # any delay value > 0 would do the trick.
163 Timer(5, lambda timer: self.register_pass_box.setFocus(True)) 167 Timer(5, lambda timer: self.register_pass_box.setFocus(True))
164 elif sender == self.register_pass_box: 168 elif sender == self.register_pass_box:
165 self.onRegister(None) 169 self.onRegister(None)
166 170
167 def onKeyUp(self, sender, keycode, modifiers): 171 def onKeyUp(self, sender, keycode, modifiers):
168 pass 172 # XXX: this is triggered after the textbox value has changed
173 if sender == self.login_box:
174 if keycode == KEY_AROBASE:
175 self.login_warning_msg.setHTML(_('<span class="formInfo">Entering a full JID is only needed to connect with an external XMPP account.</span>'))
176 elif "@" not in self.login_box.getText():
177 self.login_warning_msg.setHTML("")
169 178
170 def onKeyDown(self, sender, keycode, modifiers): 179 def onKeyDown(self, sender, keycode, modifiers):
171 pass 180 pass
172 181
173 def onLogin(self, button): 182 def onLogin(self, button):