@@ -233,7 +233,8 @@ def onCreate(self):
233233 self .password_ta .set_size (200 ,30 )
234234 self .password_ta .set_one_line (True )
235235 self .password_ta .align_to (label , lv .ALIGN .OUT_BOTTOM_MID , 5 , 0 )
236- self .password_ta .add_event_cb (self .password_ta_cb ,lv .EVENT .CLICKED ,None )
236+ self .password_ta .add_event_cb (lambda * args : mpos .ui .anim .smooth_show (self .keyboard ), lv .EVENT .CLICKED , None ) # it might be focused, but keyboard hidden (because ready/cancel clicked)
237+ self .password_ta .add_event_cb (lambda * args : mpos .ui .anim .smooth_hide (self .keyboard ), lv .EVENT .DEFOCUSED , None )
237238 print ("PasswordPage: Creating Connect button" )
238239 self .connect_button = lv .button (password_page )
239240 self .connect_button .set_size (100 ,40 )
@@ -258,45 +259,12 @@ def onCreate(self):
258259 self .keyboard = lv .keyboard (password_page )
259260 self .keyboard .align (lv .ALIGN .BOTTOM_MID ,0 ,0 )
260261 self .keyboard .set_textarea (self .password_ta )
261- self .keyboard .add_event_cb (self .keyboard_cb ,lv .EVENT .READY ,None )
262- self .keyboard .add_event_cb (self .keyboard_cb ,lv .EVENT .CANCEL ,None )
263- self .keyboard .add_event_cb (self .keyboard_value_changed_cb ,lv .EVENT .VALUE_CHANGED ,None )
264- self .hide_keyboard ()
262+ self .keyboard .add_event_cb (lambda * args : mpos .ui .anim .smooth_hide (self .keyboard ), lv .EVENT .READY , None )
263+ self .keyboard .add_event_cb (lambda * args : mpos .ui .anim .smooth_hide (self .keyboard ), lv .EVENT .CANCEL , None )
264+ self .keyboard .add_flag (lv .obj .FLAG .HIDDEN )
265265 print ("PasswordPage: Loading password page" )
266266 self .setContentView (password_page )
267267
268- def hide_keyboard (self ):
269- print ("keyboard_cb: READY or CANCEL or RETURN clicked, hiding keyboard" )
270- mpos .ui .anim .smooth_hide (self .keyboard )
271- print ("keyboard_cb: Showing Connect and Cancel buttons" )
272- self .connect_button .remove_flag (lv .obj .FLAG .HIDDEN )
273- self .cancel_button .remove_flag (lv .obj .FLAG .HIDDEN )
274-
275- def keyboard_cb (self , event ):
276- #print("keyboard_cb: Keyboard event triggered")
277- code = event .get_code ()
278- if code == lv .EVENT .READY or code == lv .EVENT .CANCEL :
279- self .hide_keyboard ()
280-
281- def keyboard_value_changed_cb (self , event ):
282- #print("keyboard value changed!")
283- #print(f"event: code={event.get_code()}, target={event.get_target()}, user_data={event.get_user_data()}, param={event.get_param()}") # event: code=32, target=<Blob>, user_data=<Blob>, param=<Blob>
284- button = self .keyboard .get_selected_button ()
285- text = self .keyboard .get_button_text (button )
286- #print(f"button {button} and text {text}")
287- if text == lv .SYMBOL .NEW_LINE :
288- print ("Newline key pressed, hiding keyboard..." )
289- hide_keyboard ()
290-
291- def password_ta_cb (self , event ):
292- print ("password_ta_cb: Password textarea clicked" )
293- print ("password_ta_cb: Hiding Connect and Cancel buttons" )
294- self .connect_button .add_flag (lv .obj .FLAG .HIDDEN )
295- self .cancel_button .add_flag (lv .obj .FLAG .HIDDEN )
296- print ("password_ta_cb: Showing keyboard" )
297- mpos .ui .anim .smooth_show (self .keyboard )
298-
299-
300268 def connect_cb (self , event ):
301269 global access_points
302270 print ("connect_cb: Connect button clicked" )
0 commit comments