comparison browser_side/register.py @ 222:759fd7386e1e

browser_side: set the focus to the first field when a tab is selected from the register panel
author souliane <souliane@mailoo.org>
date Sun, 22 Sep 2013 20:52:59 +0200
parents 9827cda1a6b0
children 531b8809d1ab
comparison
equal deleted inserted replaced
221:f3898fbb00c3 222:759fd7386e1e
132 register_but.addStyleName('red') 132 register_but.addStyleName('red')
133 register_vpanel.add(register_but) 133 register_vpanel.add(register_but)
134 134
135 self.right_side.add(login_tab, 'Login') 135 self.right_side.add(login_tab, 'Login')
136 self.right_side.add(register_tab, 'Register') 136 self.right_side.add(register_tab, 'Register')
137 self.right_side.addTabListener(self)
137 self.right_side.selectTab(0) 138 self.right_side.selectTab(0)
138 login_tab.setWidth(None) 139 login_tab.setWidth(None)
139 register_tab.setWidth(None) 140 register_tab.setWidth(None)
140 141
141 self.add(main_panel) 142 self.add(main_panel)
142 self.addFormHandler(self) 143 self.addFormHandler(self)
143 self.setAction('register_api/login') 144 self.setAction('register_api/login')
145
146 def onBeforeTabSelected(self, sender, tabIndex):
147 return True
148
149 def onTabSelected(self, sender, tabIndex):
150 if tabIndex == 0:
151 self.login_box.setFocus(True)
152 elif tabIndex == 1:
153 self.register_login_box.setFocus(True)
144 154
145 def onKeyPress(self, sender, keycode, modifiers): 155 def onKeyPress(self, sender, keycode, modifiers):
146 if keycode == KEY_ENTER: 156 if keycode == KEY_ENTER:
147 if sender == self.login_box: 157 if sender == self.login_box:
148 self.login_pass_box.setFocus(True) 158 self.login_pass_box.setFocus(True)
208 self.right_side.selectTab(0) 218 self.right_side.selectTab(0)
209 Window.alert('An email has been sent to you with your login informations\nPlease remember that this is ONLY A TECHNICAL DEMO') 219 Window.alert('An email has been sent to you with your login informations\nPlease remember that this is ONLY A TECHNICAL DEMO')
210 else: 220 else:
211 Window.alert('Submit error: %s' % result) 221 Window.alert('Submit error: %s' % result)
212 222
223
213 class RegisterBox(PopupPanel): 224 class RegisterBox(PopupPanel):
214 225
215 def __init__(self, callback, *args,**kwargs): 226 def __init__(self, callback, *args, **kwargs):
216 PopupPanel.__init__(self,*args,**kwargs) 227 PopupPanel.__init__(self, *args, **kwargs)
217 _form = RegisterPanel(callback) 228 self._form = RegisterPanel(callback)
218 self.setWidget(_form) 229 self.setWidget(self._form)
219 230
220 def onWindowResized(self, width, height): 231 def onWindowResized(self, width, height):
221 super(RegisterBox, self).onWindowResized(width, height) 232 super(RegisterBox, self).onWindowResized(width, height)
222 self.centerBox() 233 self.centerBox()
223 234
224 def show(self): 235 def show(self):
225 super(RegisterBox, self).show() 236 super(RegisterBox, self).show()
226 self.centerBox() 237 self.centerBox()
227 238 self._form.login_box.setFocus(True)