1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/examples/widgets/keyboard/lv_example_keyboard_1.py

29 lines
787 B
Python
Raw Normal View History

def ta_event_cb(e,kb):
code = e.get_code()
ta = e.get_target()
if code == lv.EVENT.FOCUSED:
kb.set_textarea(ta)
kb.clear_flag(lv.obj.FLAG.HIDDEN)
2021-02-08 09:53:03 +01:00
if code == lv.EVENT.DEFOCUSED:
kb.set_textarea(None)
kb.add_flag(lv.obj.FLAG.HIDDEN)
# Create a keyboard to use it with one of the text areas
kb = lv.keyboard(lv.scr_act())
2021-02-08 09:53:03 +01:00
# Create a text area. The keyboard will write here
ta = lv.textarea(lv.scr_act())
ta.set_width(200)
ta.align(lv.ALIGN.TOP_LEFT, 10, 10)
ta.add_event_cb(lambda e: ta_event_cb(e,kb), lv.EVENT.ALL, None)
ta.set_placeholder_text("Hello")
2021-02-08 09:53:03 +01:00
ta = lv.textarea(lv.scr_act())
ta.set_width(200)
ta.align(lv.ALIGN.TOP_RIGHT, -10, 10)
ta.add_event_cb(lambda e: ta_event_cb(e,kb), lv.EVENT.ALL, None)
2021-02-08 09:53:03 +01:00
kb.set_textarea(ta)
2021-02-08 09:53:03 +01:00