No subject
James
James
Mon Mar 15 02:42:15 EDT 2010
g</a>><br>
Date: Thu, 3 Jun 2010 16:59:10 +1000<br>
<div class=3D"im">Subject: [PATCH] hide brush when mouse leave area<br>
<br>
</div>Adds an enter and leave event handler for the drawing area, in order<=
br>
to draw or not draw the outline cursor.<br>
<br>
Tested-by: James Cameron <<a href=3D"mailto:quozl at laptop.org">quozl at lapt=
op.org</a>><br>
---<br>
=A0Area.py | =A0 20 +++++++++++++++++---<br>
=A01 files changed, 17 insertions(+), 3 deletions(-)<br>
<div class=3D"im"><br>
diff --git a/Area.py b/Area.py<br>
</div>index 570d093..a7f0bd0 100644<br>
<div class=3D"im">--- a/Area.py<br>
+++ b/Area.py<br>
@@ -97,11 +97,15 @@ class Area(gtk.DrawingArea):<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gtk.gdk.BUTTON_PRESS_MASK |<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gtk.gdk.BUTTON_RELEASE_MASK|<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gtk.gdk.EXPOSURE_MASK |<br>
</div>- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0gtk.gdk.KEY_PRESS_MASK)<br>
<div class=3D"im">-<br>
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0gtk.gdk.LEAVE_NOTIFY_MASK |<br>
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0gtk.gdk.ENTER_NOTIFY_MASK |<br>
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0gtk.gdk.KEY_PRESS_MASK)<br>
+<br>
=A0 =A0 =A0 =A0 self.connect("expose_event",self.expose)<br>
=A0 =A0 =A0 =A0 self.connect("motion_notify_event", self.mousemo=
ve)<br>
=A0 =A0 =A0 =A0 self.connect("button_press_event", self.mousedow=
n)<br>
+ =A0 =A0 =A0 =A0self.connect("leave_notify_event", self.mouselea=
ve)<br>
+ =A0 =A0 =A0 =A0self.connect("enter_notify_event", self.mouseent=
er)<br>
=A0 =A0 =A0 =A0 self.connect("button_release_event", self.mouseu=
p)<br>
=A0 =A0 =A0 =A0 self.connect("key_press_event", self.key_press)<=
br>
<br>
</div>@@ -353,8 +357,18 @@ class Area(gtk.DrawingArea):<br>
<div class=3D"im"> =A0 =A0 =A0 =A0 =A0 =A0 self.desenha =3D True<br>
=A0 =A0 =A0 =A0 widget.queue_draw()<br>
<br>
+ =A0 =A0def mouseleave(self, widget, event):<br>
+ =A0 =A0 =A0 =A0if self.tool['name'] in ['pencil','era=
ser','brush','rainbow']:<br>
+ =A0 =A0 =A0 =A0 =A0 =A0self.drawing =3D True<br>
</div><div class=3D"im">+ =A0 =A0 =A0 =A0 =A0 =A0size =3D self.tool['li=
ne size']<br>
</div>+ =A0 =A0 =A0 =A0 =A0 =A0widget.queue_draw_area(self.x_cursor-size, s=
elf.y_cursor-size, size*2, size*2)<br>
<div class=3D"im">+<br>
+ =A0 =A0def mouseenter(self, widget, event):<br>
+ =A0 =A0 =A0 =A0if self.tool['name'] in ['pencil','era=
ser','brush','rainbow']:<br>
+ =A0 =A0 =A0 =A0 =A0 =A0self.drawing =3D False<br>
</div><div class=3D"im">+ =A0 =A0 =A0 =A0 =A0 =A0size =3D self.tool['li=
ne size']<br>
</div>+ =A0 =A0 =A0 =A0 =A0 =A0widget.queue_draw_area(self.x_cursor-size, s=
elf.y_cursor-size, size*2, size*2)<br>
<div class=3D"im"><br>
-<br>
=A0 =A0 def mousemove(self,widget,event):<br>
=A0 =A0 =A0 =A0 """Make the Area object (GtkDrawingArea) re=
cognize that the mouse is moving.<br>
<br>
--<br>
</div>1.7.1<br>
<div><div></div><div class=3D"h5"><br>
--<br>
James Cameron<br>
<a href=3D"http://quozl.linux.org.au/" target=3D"_blank">http://quozl.linux=
.org.au/</a><br>
</div></div></blockquote></div><br><br>
--000e0cd5cad0183efe04882d050e--
More information about the Sugar-devel
mailing list