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.apps import Activity, Intent
|
||||||
from mpos.activity_navigator import ActivityNavigator
|
from mpos.activity_navigator import ActivityNavigator
|
||||||
|
|
||||||
|
from mpos.ui.keyboard import MposKeyboard
|
||||||
from mpos import PackageManager
|
from mpos import PackageManager
|
||||||
import mpos.config
|
import mpos.config
|
||||||
import mpos.ui
|
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_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)
|
self.textarea.add_event_cb(lambda *args: mpos.ui.anim.smooth_hide(self.keyboard), lv.EVENT.DEFOCUSED, None)
|
||||||
# Initialize keyboard (hidden initially)
|
# 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.align(lv.ALIGN.BOTTOM_MID, 0, 0)
|
||||||
self.keyboard.set_style_min_height(150, 0)
|
self.keyboard.set_style_min_height(165, 0)
|
||||||
mpos.ui.theme.fix_keyboard_button_style(self.keyboard) # Fix button visibility in light mode
|
|
||||||
self.keyboard.add_flag(lv.obj.FLAG.HIDDEN)
|
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.READY, None)
|
||||||
self.keyboard.add_event_cb(lambda *args: mpos.ui.anim.smooth_hide(self.keyboard), lv.EVENT.CANCEL, 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
|
import _thread
|
||||||
|
|
||||||
from mpos.apps import Activity, Intent
|
from mpos.apps import Activity, Intent
|
||||||
|
from mpos.ui.keyboard import MposKeyboard
|
||||||
|
|
||||||
import mpos.config
|
import mpos.config
|
||||||
import mpos.ui.anim
|
import mpos.ui.anim
|
||||||
@@ -229,13 +230,13 @@ class PasswordPage(Activity):
|
|||||||
password_page=lv.obj()
|
password_page=lv.obj()
|
||||||
print(f"show_password_page: Creating label for SSID: {self.selected_ssid}")
|
print(f"show_password_page: Creating label for SSID: {self.selected_ssid}")
|
||||||
label=lv.label(password_page)
|
label=lv.label(password_page)
|
||||||
label.set_text(f"Password for {self.selected_ssid}")
|
label.set_text(f"Password for: {self.selected_ssid}")
|
||||||
label.align(lv.ALIGN.TOP_MID,0,5)
|
label.align(lv.ALIGN.TOP_MID,0,10)
|
||||||
print("PasswordPage: Creating password textarea")
|
print("PasswordPage: Creating password textarea")
|
||||||
self.password_ta=lv.textarea(password_page)
|
self.password_ta=lv.textarea(password_page)
|
||||||
self.password_ta.set_width(lv.pct(90))
|
self.password_ta.set_width(lv.pct(90))
|
||||||
self.password_ta.set_one_line(True)
|
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)
|
self.password_ta.add_event_cb(lambda *args: self.show_keyboard(), lv.EVENT.CLICKED, None)
|
||||||
print("PasswordPage: Creating Connect button")
|
print("PasswordPage: Creating Connect button")
|
||||||
self.connect_button=lv.button(password_page)
|
self.connect_button=lv.button(password_page)
|
||||||
@@ -258,11 +259,10 @@ class PasswordPage(Activity):
|
|||||||
self.password_ta.set_text(pwd)
|
self.password_ta.set_text(pwd)
|
||||||
self.password_ta.set_placeholder_text("Password")
|
self.password_ta.set_placeholder_text("Password")
|
||||||
print("PasswordPage: Creating keyboard (hidden by default)")
|
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.align(lv.ALIGN.BOTTOM_MID,0,0)
|
||||||
self.keyboard.set_textarea(self.password_ta)
|
self.keyboard.set_textarea(self.password_ta)
|
||||||
self.keyboard.set_style_min_height(160, 0)
|
self.keyboard.set_style_min_height(165, 0)
|
||||||
mpos.ui.theme.fix_keyboard_button_style(self.keyboard) # Fix button visibility in light mode
|
|
||||||
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.READY, None)
|
||||||
self.keyboard.add_event_cb(lambda *args: self.hide_keyboard(), lv.EVENT.CANCEL, 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_flag(lv.obj.FLAG.HIDDEN)
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ more characters (including emoticons), and improved usability compared
|
|||||||
to the default LVGL keyboard.
|
to the default LVGL keyboard.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
from mpos.ui.keyboard import CustomKeyboard
|
from mpos.ui.keyboard import MposKeyboard
|
||||||
|
|
||||||
# Create keyboard
|
# Create keyboard
|
||||||
keyboard = CustomKeyboard(parent_obj)
|
keyboard = MposKeyboard(parent_obj)
|
||||||
keyboard.set_textarea(my_textarea)
|
keyboard.set_textarea(my_textarea)
|
||||||
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
|
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ import lvgl as lv
|
|||||||
import mpos.ui.theme
|
import mpos.ui.theme
|
||||||
|
|
||||||
|
|
||||||
class CustomKeyboard:
|
class MposKeyboard:
|
||||||
"""
|
"""
|
||||||
Enhanced keyboard widget with multiple layouts and emoticons.
|
Enhanced keyboard widget with multiple layouts and emoticons.
|
||||||
|
|
||||||
@@ -186,9 +186,9 @@ class CustomKeyboard:
|
|||||||
"""
|
"""
|
||||||
Forward any undefined method/attribute to the underlying LVGL keyboard.
|
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
|
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:
|
Examples:
|
||||||
keyboard.set_textarea(ta) # Works
|
keyboard.set_textarea(ta) # Works
|
||||||
@@ -218,10 +218,10 @@ def create_keyboard(parent, custom=False):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
parent: Parent LVGL object
|
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:
|
Returns:
|
||||||
CustomKeyboard instance or lv.keyboard instance
|
MposKeyboard instance or lv.keyboard instance
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
# Use custom keyboard
|
# Use custom keyboard
|
||||||
@@ -231,7 +231,7 @@ def create_keyboard(parent, custom=False):
|
|||||||
keyboard = create_keyboard(screen, custom=False)
|
keyboard = create_keyboard(screen, custom=False)
|
||||||
"""
|
"""
|
||||||
if custom:
|
if custom:
|
||||||
return CustomKeyboard(parent)
|
return MposKeyboard(parent)
|
||||||
else:
|
else:
|
||||||
keyboard = lv.keyboard(parent)
|
keyboard = lv.keyboard(parent)
|
||||||
mpos.ui.theme.fix_keyboard_button_style(keyboard)
|
mpos.ui.theme.fix_keyboard_button_style(keyboard)
|
||||||
|
|||||||
Reference in New Issue
Block a user