leave_notify after click



Hi!

I'm trying to write a custom widget using PyGTK and stumbled over a
strange issue: Clicking a drawingarea triggers leave_notify and
enter_notify (before button press and release can happen). That is, here
on Ubuntu with GTK+/PyGTK 2.12.0, but not on someone else's system with
2.12.5/2.12.1.

I've been told it's not an PyGTK issue.

Which one is the desired behaviour? I hope it's to not trigger leave by
clicking, as I need a way to check if the mouse cursor just moved onto
the widget or not.

My stripped down test code:
-----
#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk
from gtk import gdk
import gobject

# Create new widget, inherit from gtk.DrawingArea
class PopupScroller(gtk.DrawingArea):

	def __init__(self):
		super(PopupScroller, self).__init__()
		
		# gtk.Widget signals
		self.connect("enter_notify_event", self.enter_notify)
		self.connect("leave_notify_event", self.leave_notify)
		
		# unmask events
		self.add_events(gtk.gdk.ENTER_NOTIFY_MASK | gtk.gdk.LEAVE_NOTIFY_MASK)
				
	def enter_notify(self, widget, event):
		print "enter"
		#self.queue_draw()
	
	def leave_notify(self, widget, event):
		print "leave"
		#self.queue_draw()
									 
def main():
	window = gtk.Window()
	scroller = PopupScroller()

	window.add(scroller)
	scroller.set_size_request(100, 200)
	
	# Connect	
	window.connect("destroy", gtk.main_quit)
	#scroller.connect(signal, signal_cb)

	window.show_all()
    
	gtk.main()
   
if __name__ == "__main__":
    main()



-- 
Thorsten Wilms

thorwil's design for free software:
http://thorwil.wordpress.com/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]