mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Change CustomKeyboard to MposKeyboard
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from mpos.apps import Activity, Intent
|
||||
from mpos.activity_navigator import ActivityNavigator
|
||||
|
||||
from mpos.ui.keyboard import MposKeyboard
|
||||
from mpos import PackageManager
|
||||
import mpos.config
|
||||
import mpos.ui
|
||||
@@ -202,10 +203,9 @@ class SettingActivity(Activity):
|
||||
self.textarea.add_event_cb(lambda *args: mpos.ui.anim.smooth_show(self.keyboard), lv.EVENT.CLICKED, None) # it might be focused, but keyboard hidden (because ready/cancel clicked)
|
||||
self.textarea.add_event_cb(lambda *args: mpos.ui.anim.smooth_hide(self.keyboard), lv.EVENT.DEFOCUSED, None)
|
||||
# Initialize keyboard (hidden initially)
|
||||
self.keyboard = lv.keyboard(lv.layer_sys())
|
||||
self.keyboard = MposKeyboard(settings_screen_detail)
|
||||
self.keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
|
||||
self.keyboard.set_style_min_height(150, 0)
|
||||
mpos.ui.theme.fix_keyboard_button_style(self.keyboard) # Fix button visibility in light mode
|
||||
self.keyboard.set_style_min_height(165, 0)
|
||||
self.keyboard.add_flag(lv.obj.FLAG.HIDDEN)
|
||||
self.keyboard.add_event_cb(lambda *args: mpos.ui.anim.smooth_hide(self.keyboard), lv.EVENT.READY, None)
|
||||
self.keyboard.add_event_cb(lambda *args: mpos.ui.anim.smooth_hide(self.keyboard), lv.EVENT.CANCEL, None)
|
||||
|
||||
@@ -5,6 +5,7 @@ import lvgl as lv
|
||||
import _thread
|
||||
|
||||
from mpos.apps import Activity, Intent
|
||||
from mpos.ui.keyboard import MposKeyboard
|
||||
|
||||
import mpos.config
|
||||
import mpos.ui.anim
|
||||
@@ -229,13 +230,13 @@ class PasswordPage(Activity):
|
||||
password_page=lv.obj()
|
||||
print(f"show_password_page: Creating label for SSID: {self.selected_ssid}")
|
||||
label=lv.label(password_page)
|
||||
label.set_text(f"Password for {self.selected_ssid}")
|
||||
label.align(lv.ALIGN.TOP_MID,0,5)
|
||||
label.set_text(f"Password for: {self.selected_ssid}")
|
||||
label.align(lv.ALIGN.TOP_MID,0,10)
|
||||
print("PasswordPage: Creating password textarea")
|
||||
self.password_ta=lv.textarea(password_page)
|
||||
self.password_ta.set_width(lv.pct(90))
|
||||
self.password_ta.set_one_line(True)
|
||||
self.password_ta.align_to(label, lv.ALIGN.OUT_BOTTOM_MID, 0, 0)
|
||||
self.password_ta.align_to(label, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)
|
||||
self.password_ta.add_event_cb(lambda *args: self.show_keyboard(), lv.EVENT.CLICKED, None)
|
||||
print("PasswordPage: Creating Connect button")
|
||||
self.connect_button=lv.button(password_page)
|
||||
@@ -258,11 +259,10 @@ class PasswordPage(Activity):
|
||||
self.password_ta.set_text(pwd)
|
||||
self.password_ta.set_placeholder_text("Password")
|
||||
print("PasswordPage: Creating keyboard (hidden by default)")
|
||||
self.keyboard=lv.keyboard(password_page)
|
||||
self.keyboard=MposKeyboard(password_page)
|
||||
self.keyboard.align(lv.ALIGN.BOTTOM_MID,0,0)
|
||||
self.keyboard.set_textarea(self.password_ta)
|
||||
self.keyboard.set_style_min_height(160, 0)
|
||||
mpos.ui.theme.fix_keyboard_button_style(self.keyboard) # Fix button visibility in light mode
|
||||
self.keyboard.set_style_min_height(165, 0)
|
||||
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)
|
||||
|
||||
@@ -6,10 +6,10 @@ more characters (including emoticons), and improved usability compared
|
||||
to the default LVGL keyboard.
|
||||
|
||||
Usage:
|
||||
from mpos.ui.keyboard import CustomKeyboard
|
||||
from mpos.ui.keyboard import MposKeyboard
|
||||
|
||||
# Create keyboard
|
||||
keyboard = CustomKeyboard(parent_obj)
|
||||
keyboard = MposKeyboard(parent_obj)
|
||||
keyboard.set_textarea(my_textarea)
|
||||
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
|
||||
|
||||
@@ -22,7 +22,7 @@ import lvgl as lv
|
||||
import mpos.ui.theme
|
||||
|
||||
|
||||
class CustomKeyboard:
|
||||
class MposKeyboard:
|
||||
"""
|
||||
Enhanced keyboard widget with multiple layouts and emoticons.
|
||||
|
||||
@@ -186,9 +186,9 @@ class CustomKeyboard:
|
||||
"""
|
||||
Forward any undefined method/attribute to the underlying LVGL keyboard.
|
||||
|
||||
This allows CustomKeyboard to support ALL lv.keyboard methods automatically
|
||||
This allows MposKeyboard to support ALL lv.keyboard methods automatically
|
||||
without needing to manually wrap each one. Any method not defined on
|
||||
CustomKeyboard will be forwarded to self._keyboard.
|
||||
MposKeyboard will be forwarded to self._keyboard.
|
||||
|
||||
Examples:
|
||||
keyboard.set_textarea(ta) # Works
|
||||
@@ -218,10 +218,10 @@ def create_keyboard(parent, custom=False):
|
||||
|
||||
Args:
|
||||
parent: Parent LVGL object
|
||||
custom: If True, create CustomKeyboard; if False, create standard lv.keyboard
|
||||
custom: If True, create MposKeyboard; if False, create standard lv.keyboard
|
||||
|
||||
Returns:
|
||||
CustomKeyboard instance or lv.keyboard instance
|
||||
MposKeyboard instance or lv.keyboard instance
|
||||
|
||||
Example:
|
||||
# Use custom keyboard
|
||||
@@ -231,7 +231,7 @@ def create_keyboard(parent, custom=False):
|
||||
keyboard = create_keyboard(screen, custom=False)
|
||||
"""
|
||||
if custom:
|
||||
return CustomKeyboard(parent)
|
||||
return MposKeyboard(parent)
|
||||
else:
|
||||
keyboard = lv.keyboard(parent)
|
||||
mpos.ui.theme.fix_keyboard_button_style(keyboard)
|
||||
|
||||
Reference in New Issue
Block a user