1def textarea_event_handler(e, ta): 2 print("Enter was pressed. The current text is: " + ta.get_text()) 3 4 5def btnm_event_handler(e, ta): 6 obj = e.get_target() 7 txt = obj.get_btn_text(obj.get_selected_btn()) 8 if txt == lv.SYMBOL.BACKSPACE: 9 ta.del_char() 10 elif txt == lv.SYMBOL.NEW_LINE: 11 lv.event_send(ta, lv.EVENT.READY, None) 12 elif txt: 13 ta.add_text(txt) 14 15 16ta = lv.textarea(lv.scr_act()) 17ta.set_one_line(True) 18ta.align(lv.ALIGN.TOP_MID, 0, 10) 19ta.add_event_cb(lambda e: textarea_event_handler(e, ta), lv.EVENT.READY, None) 20ta.add_state(lv.STATE.FOCUSED) # To be sure the cursor is visible 21 22btnm_map = ["1", "2", "3", "\n", 23 "4", "5", "6", "\n", 24 "7", "8", "9", "\n", 25 lv.SYMBOL.BACKSPACE, "0", lv.SYMBOL.NEW_LINE, ""] 26 27btnm = lv.btnmatrix(lv.scr_act()) 28btnm.set_size(200, 150) 29btnm.align(lv.ALIGN.BOTTOM_MID, 0, -10) 30btnm.add_event_cb(lambda e: btnm_event_handler(e, ta), lv.EVENT.VALUE_CHANGED, None) 31btnm.clear_flag(lv.obj.FLAG.CLICK_FOCUSABLE) # To keep the text area focused on button clicks 32btnm.set_map(btnm_map) 33