No subject

James James
Mon Mar 15 02:42:15 EDT 2010


g</a>&gt;<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 &lt;<a href=3D"mailto:quozl at laptop.org">quozl at lapt=
op.org</a>&gt;<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(&quot;expose_event&quot;,self.expose)<br>
 =A0 =A0 =A0 =A0 self.connect(&quot;motion_notify_event&quot;, self.mousemo=
ve)<br>
 =A0 =A0 =A0 =A0 self.connect(&quot;button_press_event&quot;, self.mousedow=
n)<br>
+ =A0 =A0 =A0 =A0self.connect(&quot;leave_notify_event&quot;, self.mouselea=
ve)<br>
+ =A0 =A0 =A0 =A0self.connect(&quot;enter_notify_event&quot;, self.mouseent=
er)<br>
 =A0 =A0 =A0 =A0 self.connect(&quot;button_release_event&quot;, self.mouseu=
p)<br>
 =A0 =A0 =A0 =A0 self.connect(&quot;key_press_event&quot;, 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[&#39;name&#39;] in [&#39;pencil&#39;,&#39;era=
ser&#39;,&#39;brush&#39;,&#39;rainbow&#39;]:<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[&#39;li=
ne size&#39;]<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[&#39;name&#39;] in [&#39;pencil&#39;,&#39;era=
ser&#39;,&#39;brush&#39;,&#39;rainbow&#39;]:<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[&#39;li=
ne size&#39;]<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 &quot;&quot;&quot;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