diff --git a/internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py b/internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py index ae63a705..c4758838 100644 --- a/internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py +++ b/internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py @@ -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...") diff --git a/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py b/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py index 8aa28886..be55e76c 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py @@ -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") diff --git a/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py b/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py index 3168173e..cd11b0d1 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py @@ -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) diff --git a/internal_filesystem/builtin/apps/com.micropythonos.wifi/assets/wifi.py b/internal_filesystem/builtin/apps/com.micropythonos.wifi/assets/wifi.py index c85f4c0e..894a7ee4 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.wifi/assets/wifi.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.wifi/assets/wifi.py @@ -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): diff --git a/internal_filesystem/lib/mpos/apps.py b/internal_filesystem/lib/mpos/apps.py index 94f94a29..bd342c3b 100644 --- a/internal_filesystem/lib/mpos/apps.py +++ b/internal_filesystem/lib/mpos/apps.py @@ -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") diff --git a/internal_filesystem/lib/mpos/clipboard.py b/internal_filesystem/lib/mpos/clipboard.py index 391686a7..d63a0972 100644 --- a/internal_filesystem/lib/mpos/clipboard.py +++ b/internal_filesystem/lib/mpos/clipboard.py @@ -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)