Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-04-25 11:04:31 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-04-25 11:04:31 (GMT)
commita082d76fda730120764af09aa9bccce162cb36f9 (patch)
treee2323beff0484c9cff138454855ed041871f80ee
parent7fa3a3a868020446b17ac545163c77a9c87752cd (diff)
added mouse event support to sample code
-rw-r--r--NEWS6
-rw-r--r--tamyblock.py15
-rw-r--r--tawindow.py6
3 files changed, 26 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 6aaae11..79847a9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+87
+
+* fixed typo in sample code
+* added mouse support to sample code (See
+ http://tonyforster.blogspot.com/2010/03/mouse-support-in-turtleart.html)
+
86
* More .es updates
diff --git a/tamyblock.py b/tamyblock.py
index 0e52577..763dcb9 100644
--- a/tamyblock.py
+++ b/tamyblock.py
@@ -169,7 +169,7 @@ def myblock(lc, x):
lc.tw.canvas.setpen(False)
lc.tw.canvas.forward((lc.tw.canvas.pensize*2)-1)
dist += (lc.tw.canvas.pensize*2)
- lc.tw.canvas.forward(x-dist) # make sure we have moved exactly x
+ lc.tw.canvas.forward(x-dist) # make sure we have moved exactly x
lc.tw.canvas.setpen(True)
else:
lc.tw.canvas.forward(x)
@@ -229,4 +229,17 @@ def myblock(lc, x):
# lc.tw.save_as_image(str(x))
# return
+ ###########################################################################
+ #
+ # Push mouse event to stack
+ #
+ ###########################################################################
+ # if lc.tw.mouse_flag == 1:
+ # lc.heap.append(lc.tw.mouse_y)
+ # lc.heap.append(lc.tw.mouse_x)
+ # lc.heap.append(1) # mouse event
+ # lc.tw.mouseflag = 0
+ # else:
+ # lc.heap.append(0) # no mouse event
+ # return
diff --git a/tawindow.py b/tawindow.py
index 775c0c6..aa0bd4a 100644
--- a/tawindow.py
+++ b/tawindow.py
@@ -94,6 +94,9 @@ class TurtleArtWindow():
self.keypress = ""
self.keyvalue = 0
self.dead_key = ""
+ self.mouse_flag = 0
+ self.mouse_x = 0
+ self.mouse_y = 0
self.area = self.window.window
self.gc = self.area.new_gc()
self.orientation = HORIZONTAL_PALETTE
@@ -636,6 +639,9 @@ class TurtleArtWindow():
""" Button press """
self.window.grab_focus()
x, y = xy(event)
+ self.mouse_flag = 1
+ self.mouse_x = x
+ self.mouse_y = y
self.button_press(event.get_state()&gtk.gdk.CONTROL_MASK, x, y)
return True