Desktop: implement CTRL-V to paste

This commit is contained in:
Thomas Farstrike
2025-06-08 23:51:07 +02:00
parent a2ac601854
commit 37c546928d
2 changed files with 10 additions and 1 deletions
+2
View File
@@ -9,6 +9,7 @@ import sys
sys.path.append('lib/')
import mpos.ui
import mpos.clipboard
#TFT_HOR_RES=640
#TFT_VER_RES=480
@@ -43,6 +44,7 @@ def catch_escape_key(indev, indev_data):
import sdl_keyboard
sdlkeyboard = sdl_keyboard.SDLKeyboard()
sdlkeyboard._indev_drv.set_read_cb(catch_escape_key) # check for escape
sdlkeyboard.set_paste_text_callback(mpos.clipboard.paste_text)
#def keyboard_cb(event):
# global canvas
+8 -1
View File
@@ -1,4 +1,4 @@
# simple clipboard
import lvgl as lv
copied = None
@@ -7,3 +7,10 @@ def add(tocopy):
def get():
return copied
def paste_text(text): # called when CTRL-V is pressed on the keyboard
print(f"mpos.ui.clipboard.py paste_text adding {text}")
group = lv.group_get_default()
focused_obj = group.get_focused()
if focused_obj and isinstance(focused_obj, lv.textarea):
focused_obj.add_text(text)