From 24dd5a50def12c17f2c9b7f8aa1537851a39529f Mon Sep 17 00:00:00 2001 From: "Jeison Yehuda Amihud (Blender Dumbass)" Date: Fri, 11 Dec 2020 17:21:19 +0000 Subject: [PATCH] Upload files to 'UI' --- UI/UI_elements.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/UI/UI_elements.py b/UI/UI_elements.py index c411eba..533f210 100644 --- a/UI/UI_elements.py +++ b/UI/UI_elements.py @@ -580,7 +580,8 @@ def scroll_area(layer, win, name, x, y, width, height, maxlength, def text(outlayer, win, name, x, y, width, height, set_text="", parse=False, fill=True, - editable=True, multiline=False , linebreak=False, centered=False, tip=""): + editable=True, multiline=False , linebreak=False, centered=False, tip="", + offset=[0,0]): # This function will handle all the text writting in the software. # I'm not sure about how parsing going to work for script files later. @@ -676,10 +677,10 @@ def text(outlayer, win, name, x, y, width, height, set_text="", parse=False, fil # Mouse select if win.current["LMB"]: - if int(win.current["mx"]) in range(int(x), int(x+width))\ - and int(win.current["my"]) in range(int(y), int(y+height)): - win.text[name]["cursor"][0] = int((win.current["LMB"][0]-x-offsetX)/12) - win.text[name]["cursor"][1] = int((win.current["mx"]-x-offsetX)/12) + if int(win.current["mx"]-offset[0]) in range(int(x), int(x+width))\ + and int(win.current["my"]-offset[1]) in range(int(y), int(y+height)): + win.text[name]["cursor"][0] = int((win.current["LMB"][0]-x-offsetX-offset[0])/12) + win.text[name]["cursor"][1] = int((win.current["mx"]-x-offsetX-offset[0])/12) # If second part of selection ends up bigger then the first. Reverse them. if win.text[name]["cursor"][0] > win.text[name]["cursor"][1]: @@ -712,9 +713,10 @@ def text(outlayer, win, name, x, y, width, height, set_text="", parse=False, fil # Let's filter the input first. # For example if not multiline: #Removing enter key press - if 65293 in win.current["keys"] or 65421 in win.current["keys"]: + if 65293 in win.current["keys"] or 65421 in win.current["keys"]\ + or 65289 in win.current["keys"]: # TAB win.current["key_letter"] = "" - + prevlen = len(win.text[name]["text"]) clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) @@ -847,7 +849,8 @@ def text(outlayer, win, name, x, y, width, height, set_text="", parse=False, fil 10, fill=False, button=do, - tip=tip) + tip=tip, + offset=offset) outlayer.stroke() if win.textactive == name: