Skip to content

Commit 74a9400

Browse files
InputManager: mark emulate_focus_obj(group,o) as deprecated in favor of lv.group_focus_obj(o)
1 parent 357bcad commit 74a9400

6 files changed

Lines changed: 18 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ Future release (next version)
33

44
Put unreleased changes here!
55

6+
67
Builtin Apps:
7-
- Bundle these as compiled bytecode .mpy files to reduce build size by 60KiB and improve performance
8+
- Bundle as compiled bytecode .mpy files to reduce build size by 60KiB and improve performance
89
- About: show system uptime
910
- HowTo app: make import lvgl as lv explicit
1011

1112
Frameworks:
1213
- AppManager: try .mpy after .py and use import instead of explicit compile
1314
- AppManager: require explicit import lvgl for clarity
15+
- InputManager: mark emulate_focus_obj(group,o) as deprecated in favor of lv.group_focus_obj(o)
1416
- SharedPreferences: avoid writing default-only configs at boot and prune empty config dirs/files
1517

1618
OS:

internal_filesystem/apps/com.micropythonos.file_manager/assets/file_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import lvgl as lv
3-
from mpos import Activity, InputManager, Intent, sdcard
3+
from mpos import Activity, Intent, sdcard
44
from rename_activity import RenameActivity
55

66

@@ -117,7 +117,7 @@ def _focus_action_bar(self):
117117
return
118118
group = lv.group_get_default()
119119
if group:
120-
InputManager.emulate_focus_obj(group, self._cancel_btn)
120+
lv.group_focus_obj(self._cancel_btn)
121121

122122
def _show_action_bar(self):
123123
self._dismiss_action_bar()

internal_filesystem/lib/mpos/ui/focus_direction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ def process_object(obj, depth=0):
145145
return closest_obj
146146

147147
def move_focus_direction(angle):
148-
from .input_manager import InputManager
149148
focus_group = lv.group_get_default()
150149
if not focus_group:
151150
print("move_focus_direction: no default focus_group found, returning...")
@@ -174,4 +173,4 @@ def move_focus_direction(angle):
174173
if o:
175174
#print("move_focus_direction: moving focus to:")
176175
#mpos.util.print_lvgl_widget(o)
177-
InputManager.emulate_focus_obj(focus_group, o)
176+
lv.group_focus_obj(o)

internal_filesystem/lib/mpos/ui/input_manager.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,17 @@ def pointer_xy(cls):
8585
@classmethod
8686
def emulate_focus_obj(cls, focusgroup, target):
8787
"""
88-
Emulate setting focus to a specific object in the focus group.
89-
This function is needed because the current version of LVGL doesn't have a direct set_focus method.
90-
It should exist, according to the API, so maybe it will be available in the next release and this function might no longer be needed someday.
88+
Deprecated compatibility shim.
89+
90+
Use lv.group_focus_obj(target) directly.
9191
"""
92-
if not focusgroup:
93-
print("emulate_focus_obj needs a focusgroup, returning...")
94-
return
9592
if not target:
9693
print("emulate_focus_obj needs a target, returning...")
9794
return
98-
for objnr in range(focusgroup.get_obj_count()):
99-
currently_focused = focusgroup.get_focused()
100-
if currently_focused is target:
101-
return
102-
else:
103-
focusgroup.focus_next()
104-
print("WARNING: emulate_focus_obj failed to find target")
95+
96+
print(
97+
"WARNING: InputManager.emulate_focus_obj() is deprecated and unnecessary. "
98+
"Use lv.group_focus_obj(target) directly."
99+
)
100+
101+
lv.group_focus_obj(target)

internal_filesystem/lib/mpos/ui/keyboard.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ def scroll_after_show(self, timer):
248248
def focus_on_keyboard(self, timer=None):
249249
default_group = lv.group_get_default()
250250
if default_group:
251-
from .input_manager import InputManager
252-
from .focus_direction import move_focus_direction
253-
InputManager.emulate_focus_obj(default_group, self._keyboard)
251+
lv.group_focus_obj(self._keyboard)
254252

255253
def scroll_back_after_hide(self, timer):
256254
self._parent.scroll_to_y(self._saved_scroll_y, True)

internal_filesystem/lib/mpos/ui/view.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ def back_screen():
9797
if default_group:
9898
from .focus import move_focusgroup_objects
9999
move_focusgroup_objects(prev_focusgroup, default_group)
100-
from .input_manager import InputManager
101-
InputManager.emulate_focus_obj(default_group, prev_focused)
100+
lv.group_focus_obj(prev_focused)
102101

103102
if prev_activity:
104103
prev_activity.onResume(prev_screen)

0 commit comments

Comments
 (0)