Editing text works.

This commit is contained in:
Skyler Lehmkuhl 2012-08-01 10:32:07 -04:00
parent 22b08e2461
commit 39b725ec4b
2 changed files with 22 additions and 0 deletions

View File

@ -96,6 +96,7 @@ def onMouseDownGroup(self, x, y):
MainWindow.scriptwindow.text = self.activelayer.frames[self.activelayer.currentframe].actions MainWindow.scriptwindow.text = self.activelayer.frames[self.activelayer.currentframe].actions
elif svlgui.MODE in ["t"]: elif svlgui.MODE in ["t"]:
self.ctext = svlgui.Text("Mimimi",x,y) self.ctext = svlgui.Text("Mimimi",x,y)
self.ctext.editing = True
self.ctext.onMouseDown = onMouseDownText self.ctext.onMouseDown = onMouseDownText
self.ctext.onMouseDrag = onMouseDragText self.ctext.onMouseDrag = onMouseDragText
self.ctext.onMouseUp = onMouseUpText self.ctext.onMouseUp = onMouseUpText

View File

@ -1709,6 +1709,7 @@ class Text (object):
self.hwaccel = None self.hwaccel = None
self.type="Text" self.type="Text"
self.name = "t"+str(int(random.random()*10000))+str(SITER) self.name = "t"+str(int(random.random()*10000))+str(SITER)
self.editing = False
SITER+=1 SITER+=1
def draw(self,cr=None,parent=None,rect=None): def draw(self,cr=None,parent=None,rect=None):
if SYSTEM=="osx": if SYSTEM=="osx":
@ -1731,6 +1732,20 @@ class Text (object):
cr.translate(self.x*math.cos(radrot)-self.y*math.sin(radrot), self.x*math.sin(radrot)+self.y*math.cos(radrot)) cr.translate(self.x*math.cos(radrot)-self.y*math.sin(radrot), self.x*math.sin(radrot)+self.y*math.cos(radrot))
else: else:
cr.translate(self.x,self.y) cr.translate(self.x,self.y)
if self.editing:
w = self.font.width(self.text)
d = self.font.descent
h = self.font.height
cr.newpath()
cr.moveto(0,d)
cr.lineto(w,d)
cr.lineto(w,-h)
cr.lineto(0,-h)
cr.lineto(0,d)
cr.pencolor = Color([0,0,0]).pygui
cr.fillcolor = Color([1,1,1]).pygui
cr.fill_stroke()
cr.fill()
cr.newpath() cr.newpath()
cr.moveto(0,0) cr.moveto(0,0)
cr.show_text(self.text) cr.show_text(self.text)
@ -1768,6 +1783,12 @@ class Text (object):
def onMouseMove(self, self1, x, y): def onMouseMove(self, self1, x, y):
pass pass
def onKeyDown(self, self1, key): def onKeyDown(self, self1, key):
if key == "\b":
self.text = self.text[:-1]
elif key == "enter":
self.text = self.text+"\n"
else:
self.text+=str(key)
pass pass
def onKeyUp(self, self1, key): def onKeyUp(self, self1, key):
pass pass