mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
waveshare: fix focusgroup handling
This commit is contained in:
@@ -165,23 +165,23 @@ class ImageView(Activity):
|
||||
self.show_next_image()
|
||||
|
||||
def unfocus(self):
|
||||
group = lv.group_get_default()
|
||||
if not group:
|
||||
focusgroup = lv.group_get_default()
|
||||
if not focusgroup:
|
||||
print("WARNING: imageview.py could not get default focus group")
|
||||
return
|
||||
print("got focus group")
|
||||
# group.focus_obj(self.play_button) would be better but appears missing?!
|
||||
focused = group.get_focused()
|
||||
focused = focusgroup.get_focused()
|
||||
print("got focus button")
|
||||
#focused.remove_state(lv.STATE.FOCUSED) # this doesn't seem to work to remove focus
|
||||
if focused:
|
||||
print("checking which button is focused")
|
||||
if focused == self.next_button:
|
||||
print("next is focused")
|
||||
group.focus_prev()
|
||||
focusgroup.focus_prev()
|
||||
elif focused == self.prev_button:
|
||||
print("prev is focused")
|
||||
group.focus_next()
|
||||
focusgroup.focus_next()
|
||||
else:
|
||||
print("focus isn't on next or previous, leaving it...")
|
||||
|
||||
|
||||
@@ -107,7 +107,8 @@ class Launcher(mpos.apps.Activity):
|
||||
app_cont.add_event_cb(lambda e, path=app_dir_fullpath: mpos.apps.start_app(path), lv.EVENT.CLICKED, None)
|
||||
app_cont.add_event_cb(lambda e, app_cont=app_cont: self.focus_app_cont(app_cont),lv.EVENT.FOCUSED,None)
|
||||
app_cont.add_event_cb(lambda e, app_cont=app_cont: self.defocus_app_cont(app_cont),lv.EVENT.DEFOCUSED,None)
|
||||
focusgroup.add_obj(app_cont)
|
||||
if focusgroup:
|
||||
focusgroup.add_obj(app_cont)
|
||||
|
||||
end = time.ticks_ms()
|
||||
print(f"Redraw icons took: {end-start}ms")
|
||||
|
||||
@@ -92,7 +92,8 @@ class SettingsActivity(Activity):
|
||||
setting_cont.add_event_cb(lambda e, s=setting: self.startSettingActivity(s), lv.EVENT.CLICKED, None)
|
||||
setting_cont.add_event_cb(lambda e, container=setting_cont: self.focus_container(container),lv.EVENT.FOCUSED,None)
|
||||
setting_cont.add_event_cb(lambda e, container=setting_cont: self.defocus_container(container),lv.EVENT.DEFOCUSED,None)
|
||||
focusgroup.add_obj(setting_cont)
|
||||
if focusgroup:
|
||||
focusgroup.add_obj(setting_cont)
|
||||
|
||||
def startSettingActivity(self, setting):
|
||||
intent = Intent(activity_class=SettingActivity)
|
||||
|
||||
@@ -314,13 +314,15 @@ class PasswordPage(Activity):
|
||||
self.cancel_button.add_flag(lv.obj.FLAG.HIDDEN)
|
||||
mpos.ui.anim.smooth_show(self.keyboard)
|
||||
focusgroup = lv.group_get_default()
|
||||
focusgroup.focus_next() # move the focus to the keypad
|
||||
if focusgroup:
|
||||
focusgroup.focus_next() # move the focus to the keypad
|
||||
|
||||
def hide_keyboard(self):
|
||||
self.connect_button.remove_flag(lv.obj.FLAG.HIDDEN)
|
||||
self.cancel_button.remove_flag(lv.obj.FLAG.HIDDEN)
|
||||
focusgroup = lv.group_get_default()
|
||||
focusgroup.focus_prev() # move the focus to the close button, otherwise it goes back to the textarea, which opens the keyboard again
|
||||
if focusgroup:
|
||||
focusgroup.focus_prev() # move the focus to the close button, otherwise it goes back to the textarea, which opens the keyboard again
|
||||
mpos.ui.anim.smooth_hide(self.keyboard)
|
||||
|
||||
def print_events(self, event):
|
||||
|
||||
@@ -335,9 +335,9 @@ class ActivityNavigator:
|
||||
activity._result_callback = result_callback # Pass callback to activity
|
||||
start_time = utime.ticks_ms()
|
||||
# Remove objects from previous screens from the focus group:
|
||||
group = lv.group_get_default()
|
||||
if group: # on esp32 this may not be set
|
||||
group.remove_all_objs() # might be better to save and restore the group for "back" actions
|
||||
focusgroup = lv.group_get_default()
|
||||
if focusgroup: # on esp32 this may not be set
|
||||
focusgroup.remove_all_objs() # might be better to save and restore the group for "back" actions
|
||||
activity.onCreate()
|
||||
end_time = utime.ticks_diff(utime.ticks_ms(), start_time)
|
||||
print(f"apps.py _launch_activity: activity.onCreate took {end_time}ms")
|
||||
|
||||
@@ -10,9 +10,9 @@ def get():
|
||||
|
||||
def paste_text(text): # called when CTRL-V is pressed on the keyboard
|
||||
print(f"mpos.ui.clipboard.py paste_text adding {text}")
|
||||
group = lv.group_get_default()
|
||||
if not group:
|
||||
focusgroup = lv.group_get_default()
|
||||
if not focusgroup:
|
||||
return
|
||||
focused_obj = group.get_focused()
|
||||
focused_obj = focusgroup.get_focused()
|
||||
if focused_obj and isinstance(focused_obj, lv.textarea):
|
||||
focused_obj.add_text(text)
|
||||
|
||||
Reference in New Issue
Block a user