i am developing a Gtk# based application which uses a custom widget derived from Gtk.Bin. For some reason not known to me, it does not receive mouse movement events. The code below is never called:
[GLib.ConnectBefore]
protected override bool OnMotionNotifyEvent (Gdk.EventMotion evnt)
{
Console.Out.WriteLine( "Mouse move!" );
return base.OnMotionNotifyEvent (evnt);
}
I have also extended the Event mask of the widget to receive all events (in the constructor):
AddEvents(( int ) Gdk.EventMask.AllEventsMask );
Any ideas?
Gtk.Bin is a windowless container so it does not receive mouse events by default.
You can create a Gdk.Window manually in your subclass in order to receive mouse events, or the easier path is to subclass Gtk.EventBox, which is a Gtk.Bin subclass designed for this purpose by internally creating its own Gdk window.