|
1 | 1 | import lvgl as lv |
| 2 | +from lvgl import LvReferenceError |
2 | 3 | from .anim import smooth_show, smooth_hide |
3 | 4 | from .view import back_screen |
4 | 5 | from .topmenu import open_drawer, drawer_open, NOTIFICATION_BAR_HEIGHT |
|
17 | 18 | def is_short_movement(dx, dy): |
18 | 19 | return dx < short_movement_threshold and dy < short_movement_threshold |
19 | 20 |
|
| 21 | +def _passthrough_click(x, y, indev): |
| 22 | + obj = lv.indev_search_obj(lv.screen_active(), lv.point_t({'x': x, 'y': y})) |
| 23 | + # print(f"Found object: {obj}") |
| 24 | + if obj: |
| 25 | + try: |
| 26 | + # print(f"Simulating press/click/release on {obj}") |
| 27 | + obj.send_event(lv.EVENT.PRESSED, indev) |
| 28 | + obj.send_event(lv.EVENT.CLICKED, indev) |
| 29 | + obj.send_event(lv.EVENT.RELEASED, indev) # gets lost |
| 30 | + except LvReferenceError as e: |
| 31 | + print(f"Object to click is gone: {e}") |
| 32 | + |
20 | 33 | def _back_swipe_cb(event): |
21 | 34 | if drawer_open: |
22 | 35 | print("ignoring back gesture because drawer is open") |
@@ -51,13 +64,7 @@ def _back_swipe_cb(event): |
51 | 64 | back_screen() |
52 | 65 | elif is_short_movement(dx, dy): |
53 | 66 | # print("Short movement - treating as tap") |
54 | | - obj = lv.indev_search_obj(lv.screen_active(), lv.point_t({'x': x, 'y': y})) |
55 | | - # print(f"Found object: {obj}") |
56 | | - if obj: |
57 | | - # print(f"Simulating press/click/release on {obj}") |
58 | | - obj.send_event(lv.EVENT.PRESSED, indev) |
59 | | - obj.send_event(lv.EVENT.CLICKED, indev) |
60 | | - obj.send_event(lv.EVENT.RELEASED, indev) |
| 67 | + _passthrough_click(x, y, indev) |
61 | 68 |
|
62 | 69 | def _top_swipe_cb(event): |
63 | 70 | if drawer_open: |
@@ -95,13 +102,7 @@ def _top_swipe_cb(event): |
95 | 102 | open_drawer() |
96 | 103 | elif is_short_movement(dx, dy): |
97 | 104 | # print("Short movement - treating as tap") |
98 | | - obj = lv.indev_search_obj(lv.screen_active(), lv.point_t({'x': x, 'y': y})) |
99 | | - # print(f"Found object: {obj}") |
100 | | - if obj : |
101 | | - # print(f"Simulating press/click/release on {obj}") |
102 | | - obj.send_event(lv.EVENT.PRESSED, indev) |
103 | | - obj.send_event(lv.EVENT.CLICKED, indev) |
104 | | - obj.send_event(lv.EVENT.RELEASED, indev) |
| 105 | + _passthrough_click(x, y, indev) |
105 | 106 |
|
106 | 107 | def handle_back_swipe(): |
107 | 108 | global backbutton |
|
0 commit comments