Color selection windows close automatically

This commit is contained in:
Skyler Lehmkuhl 2012-01-12 11:15:36 -05:00
parent d13b6588f7
commit 852003809b
2 changed files with 23 additions and 5 deletions

View File

@ -177,8 +177,10 @@ def run_file(self=None):
osx_flash_player_loc = "/Applications/Flash\ Player\ Debugger.app"
svlgui.execute("open -a "+osx_flash_player_loc+" test.swf")
elif svlgui.PLATFORM=='win32':
win_flash_player_loc = ""
svlgui.execute('start '+win_flash_player_loc+" test.swf")
elif svlgui.PLATFORM.startswith('linux'):
linux_flash_player_loc = ""
svlgui.execute('xdg-open '+linux_flash_player_loc+" test.swf")
@ -218,8 +220,8 @@ e.onMouseDown = onMouseDownObj
e.onMouseMove = onMouseMoveObj
e.onMouseDrag = onMouseDragObj
e.onMouseUp = onMouseUpObj
e.onKeyDown = onKeyDownObj'''
root.add(e)
e.onKeyDown = onKeyDownObj
root.add(e)'''

View File

@ -37,6 +37,8 @@ CURRENTFRAME=0
#Object which has the keyboard focus.
FOCUS = None
#Library. Contatins all objects whether displayed or not.
Library = []
@ -241,7 +243,12 @@ if SYSTEM=="osx":
app = Lightningbeam()
elif SYSTEM=="html":
app = ""
class ObjectDeletedError:
def __str__(self):
return "Object deleted!"
class htmlobj:
"""
@ -687,8 +694,11 @@ class Canvas(Widget):
def mouse_down(self, event):
self.become_target()
x, y = event.position
for i in self.objs:
i._onMouseDown(x, y)
try:
for i in self.objs:
i._onMouseDown(x, y)
except ObjectDeletedError:
return
self.invalidate_rect([0,0,self.extent[0],self.extent[1]])
def mouse_drag(self, event):
@ -1614,8 +1624,8 @@ class Group (object):
self.activelayer.currentselect._onMouseDown(self.activelayer.currentselect, x, y)
else:
if MODE in [" ", "s", "b"]:
test = False
for i in reversed(self.currentFrame()):
test = False
if i.hitTest(x, y):
if MODE in [" ", "s"]:
self.activelayer.currentselect = i
@ -1876,9 +1886,13 @@ class ColorSelectionWindow:
def onClickRectFill(self,x,y):
global FILLCOLOR
FILLCOLOR = Color(colors.colorArray(int(x/16))[int(y/16)])
self.window.destroy()
raise ObjectDeletedError
def onClickRectLine(self,x,y):
global LINECOLOR
LINECOLOR = Color(colors.colorArray(int(x/16))[int(y/16)])
self.window.destroy()
raise ObjectDeletedError
canvas = Canvas(336,208)
group = Group()
def dummy(*args):
@ -1887,6 +1901,8 @@ class ColorSelectionWindow:
canvas.add(group,0,0)
im = Image("media/colors.png")
group.add(im)
group.window = win
group.canvas = canvas
if var=="fill":
group.onMouseDown = onClickRectFill
if var=="line":