@@ -256,15 +256,11 @@ def scroll_after_show(self, timer):
256256 #self._textarea.scroll_to_view_recursive(True) # makes sense but doesn't work and breaks the keyboard scroll
257257 self ._keyboard .scroll_to_view_recursive (True )
258258
259- def focus_on_keyboard (self , timer ):
260- # Would be good to focus on the keyboard,
261- # but somehow the focus styling is not applied,
262- # so the user doesn't see which button is selected...
259+ def focus_on_keyboard (self , timer = None ):
263260 default_group = lv .group_get_default ()
264261 if default_group :
265262 from .focus_direction import emulate_focus_obj , move_focus_direction
266263 emulate_focus_obj (default_group , self ._keyboard )
267- move_focus_direction (180 ) # Same issue
268264
269265 def scroll_back_after_hide (self , timer ):
270266 self ._parent .scroll_to_y (self ._saved_scroll_y , True )
@@ -273,8 +269,14 @@ def show_keyboard(self):
273269 self ._saved_scroll_y = self ._parent .get_scroll_y ()
274270 mpos .ui .anim .smooth_show (self ._keyboard , duration = 500 )
275271 # Scroll to view on a timer because it will be hidden initially
276- lv .timer_create (self .scroll_after_show ,250 ,None ).set_repeat_count (1 )
277- #focus_timer = lv.timer_create(self.focus_on_keyboard,750,None).set_repeat_count(1)
272+ lv .timer_create (self .scroll_after_show , 250 , None ).set_repeat_count (1 )
273+ # When this is done from a timer, focus styling is not applied so the user doesn't see which button is selected.
274+ # Maybe because there's no active indev anymore?
275+ # Maybe it will be fixed in an update of LVGL 9.3?
276+ # focus_timer = lv.timer_create(self.focus_on_keyboard,750,None).set_repeat_count(1)
277+ # Workaround: show the keyboard immediately and then focus on it - that works, and doesn't seem to flicker as feared:
278+ self ._keyboard .remove_flag (lv .obj .FLAG .HIDDEN )
279+ self .focus_on_keyboard ()
278280
279281 def hide_keyboard (self ):
280282 mpos .ui .anim .smooth_hide (self ._keyboard , duration = 500 )
0 commit comments