You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Desktop: implement CTRL-V to paste
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user