From f3fb400b19b8a1b60f7637137210396e12c7858c Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Wed, 8 Oct 2025 16:20:48 +0200 Subject: [PATCH] wifi.py: small reworks --- .../com.micropythonos.wifi/assets/wifi.py | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) 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 a98669ca..c85f4c0e 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.wifi/assets/wifi.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.wifi/assets/wifi.py @@ -226,26 +226,6 @@ class WiFi(Activity): lv.async_call(lambda l: self.refresh_list(), None) -def print_events(event): - event_code=event.get_code() - #print(f"got event {event_code}") - # Ignore: - # ======= - # 19: HIT_TEST - # COVER_CHECK - # DRAW_MAIN - # DRAW_MAIN_BEGIN - # DRAW_MAIN_END - # DRAW_POST - # DRAW_POST_BEGIN - # DRAW_POST_END - # 39: CHILD_CHANGED - # GET_SELF_SIZE - if event_code not in [19,23,25,26,27,28,29,30,39,49]: - name = mpos.ui.get_event_name(event_code) - print(f"lv_event_t: code={event_code}, name={name}") - target=event.get_target() - print(f"target: {target}") @@ -304,7 +284,7 @@ class PasswordPage(Activity): self.keyboard.add_event_cb(lambda *args: self.hide_keyboard(), lv.EVENT.READY, None) self.keyboard.add_event_cb(lambda *args: self.hide_keyboard(), lv.EVENT.CANCEL, None) self.keyboard.add_flag(lv.obj.FLAG.HIDDEN) - self.keyboard.add_event_cb(print_events, lv.EVENT.ALL, None) + self.keyboard.add_event_cb(self.print_events, lv.EVENT.ALL, None) print("PasswordPage: Loading password page") self.setContentView(password_page) @@ -343,6 +323,40 @@ class PasswordPage(Activity): 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): + event_code=event.get_code() + #print(f"got event {event_code}") + # Ignore: + # ======= + # 19: HIT_TEST + # COVER_CHECK + # DRAW_MAIN + # DRAW_MAIN_BEGIN + # DRAW_MAIN_END + # DRAW_POST + # DRAW_POST_BEGIN + # DRAW_POST_END + # 39: CHILD_CHANGED + # GET_SELF_SIZE + if event_code not in [19,23,25,26,27,28,29,30,39,49]: + name = mpos.ui.get_event_name(event_code) + print(f"lv_event_t: code={event_code}, name={name}") + #target=event.get_target() + #print(f"target: {target}") # blob + if event_code == lv.EVENT.VALUE_CHANGED: + button = self.keyboard.get_selected_button() + text = self.keyboard.get_button_text(button) + print(f"button {button} and text {text}") + if text == lv.SYMBOL.NEW_LINE: + print("Newline pressed, would be nice to close the keyboard but that triggers the cancel button...") + #self.hide_keyboard() # makes cancel button click! + #self.keyboard.send_event(lv.EVENT.READY, None) + # workaround: dont change focus to cancel button: + #self.connect_button.remove_flag(lv.obj.FLAG.HIDDEN) + #self.cancel_button.remove_flag(lv.obj.FLAG.HIDDEN) + #mpos.ui.anim.smooth_hide(self.keyboard) + # => doesnt work because then the focus goes back to the keyboard which reopens + @staticmethod def setPassword(ssid, password): global access_points