Skip to content

Commit 37c5469

Browse files
Desktop: implement CTRL-V to paste
1 parent a2ac601 commit 37c5469

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

internal_filesystem/boot_unix.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
sys.path.append('lib/')
1010

1111
import mpos.ui
12+
import mpos.clipboard
1213

1314
#TFT_HOR_RES=640
1415
#TFT_VER_RES=480
@@ -43,6 +44,7 @@ def catch_escape_key(indev, indev_data):
4344
import sdl_keyboard
4445
sdlkeyboard = sdl_keyboard.SDLKeyboard()
4546
sdlkeyboard._indev_drv.set_read_cb(catch_escape_key) # check for escape
47+
sdlkeyboard.set_paste_text_callback(mpos.clipboard.paste_text)
4648

4749
#def keyboard_cb(event):
4850
# global canvas
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# simple clipboard
1+
import lvgl as lv
22

33
copied = None
44

@@ -7,3 +7,10 @@ def add(tocopy):
77

88
def get():
99
return copied
10+
11+
def paste_text(text): # called when CTRL-V is pressed on the keyboard
12+
print(f"mpos.ui.clipboard.py paste_text adding {text}")
13+
group = lv.group_get_default()
14+
focused_obj = group.get_focused()
15+
if focused_obj and isinstance(focused_obj, lv.textarea):
16+
focused_obj.add_text(text)

0 commit comments

Comments
 (0)