Skip to content

Commit 1095880

Browse files
wificonf: capture keyboard return / nextline key
1 parent f65241a commit 1095880

File tree

2 files changed

+19
-6
lines changed
  • internal_filesystem

2 files changed

+19
-6
lines changed

internal_filesystem/apps/com.example.draw/assets/draw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def touch_cb(event):
125125
if event_code not in [23,25,26,27,28,29,30,49]:
126126
name = get_event_name(event_code)
127127
#x, y = get_xy()
128-
#print(f"lv_event_t: code={event_code}, name={name}, x={x}, y={y}")
128+
#print(f"lv_event_t: code={event_code}, name={name}, x={x}, y={y}") # target={event.get_target()}, user_data={event.get_user_data()}, param={event.get_param()}
129129
if event_code == lv.EVENT.PRESSING: # this is probably enough
130130
#if event_code in [lv.EVENT.PRESSED, lv.EVENT.PRESSING, lv.EVENT.LONG_PRESSED, lv.EVENT.LONG_PRESSED_REPEAT]:
131131
x, y = get_xy()

internal_filesystem/builtin/apps/com.example.wificonf/assets/wificonf.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import lvgl as lv
88
import _thread
99

10-
11-
1210
ssids=[]
1311
busy_scanning=False
1412
busy_connecting=False
@@ -189,14 +187,27 @@ def keyboard_cb(event):
189187
print("keyboard_cb: Keyboard event triggered")
190188
global keyboard,connect_button,cancel_button
191189
code=event.get_code()
192-
if code==lv.EVENT.READY:
193-
print("keyboard_cb: OK/Checkmark clicked, hiding keyboard")
190+
if code==lv.EVENT.READY or code==lv.EVENT.CANCEL:
191+
print("keyboard_cb: READY or CANCEL clicked, hiding keyboard")
194192
keyboard.set_height(0)
195193
keyboard.remove_flag(lv.obj.FLAG.CLICKABLE)
196194
print("keyboard_cb: Showing Connect and Cancel buttons")
197195
connect_button.remove_flag(lv.obj.FLAG.HIDDEN)
198196
cancel_button.remove_flag(lv.obj.FLAG.HIDDEN)
199197

198+
def keyboard_value_changed_cb(event):
199+
global keyboard
200+
print("keyboard value changed!")
201+
print(f"event: code={event.get_code()}, target={event.get_target()}, user_data={event.get_user_data()}, param={event.get_param()}") # event: code=32, target=<Blob>, user_data=<Blob>, param=<Blob>
202+
#keyboard = event.get_target().__cast__(lv.keyboard) # SyntaxError: Can't convert to keyboard!
203+
#keyboard = event.get_target().__cast__(lv.keyboard_class) # SyntaxError: Cast argument must be a type!
204+
#print("got keyboard!")
205+
button = keyboard.get_selected_button()
206+
text = keyboard.get_button_text(button)
207+
print(f"button {button} and text {text}")
208+
if text == lv.SYMBOL.NEW_LINE:
209+
print("It's the return key!")
210+
200211
def password_ta_cb(event):
201212
print("password_ta_cb: Password textarea clicked")
202213
global keyboard,connect_button,cancel_button
@@ -205,7 +216,7 @@ def password_ta_cb(event):
205216
cancel_button.add_flag(lv.obj.FLAG.HIDDEN)
206217
print("password_ta_cb: Showing keyboard")
207218
keyboard.set_height(160)
208-
keyboard.add_flag(lv.obj.FLAG.CLICKABLE)
219+
#keyboard.add_flag(lv.obj.FLAG.CLICKABLE)
209220

210221
def show_password_page(ssid):
211222
global password_page,password_ta,keyboard,connect_button,cancel_button
@@ -234,6 +245,8 @@ def show_password_page(ssid):
234245
keyboard.align(lv.ALIGN.BOTTOM_LEFT,0,0)
235246
keyboard.set_textarea(password_ta)
236247
keyboard.add_event_cb(keyboard_cb,lv.EVENT.READY,None)
248+
keyboard.add_event_cb(keyboard_cb,lv.EVENT.CANCEL,None)
249+
keyboard.add_event_cb(keyboard_value_changed_cb,lv.EVENT.VALUE_CHANGED,None)
237250
print("show_password_page: Creating Connect button")
238251
connect_button=lv.button(password_page)
239252
connect_button.set_size(100,40)

0 commit comments

Comments
 (0)