Re: GtkButton, enter-notify signal, and GdkWindow



I was already trying gtk_widget_add_events with GDK_ENTER_NOTIFY_MASK in my GtkWidget subclass init function 
(not the class initialization; the widget instance init function), and it wasn't working.  Following up on 
your suggestion though, I just tried overriding the realize function, hoping that would communicate the 
requirement for the enter notification up to the GdkWindow, which I think would exist by the time realize 
happens.  It still didn't work though: no notifications.

The offending widget subclass isn't getting enter notification, but the button subclass that it contains does 
receive them.  So the real question is why the contained button can get them but the container widget around 
it cannot.  I would speculate that it's because, as I pointed out before, GtkButton is calling 
gdk_window_new, but I'm confused as to why the GtkButton would be carrying the GTK_NO_WINDOW flag.

Thanks,
Brian



--- On Tue, 11/23/10, Mike Massonnet <mmassonnet gmail com> wrote:

From: Mike Massonnet <mmassonnet gmail com>
Subject: Re: GtkButton, enter-notify signal, and GdkWindow
To: "Brian Tietz" <sdbtietz yahoo com>
Cc: gtk-app-devel-list gnome org
Date: Tuesday, November 23, 2010, 11:44 PM
Hi,

2010/11/24 Brian Tietz <sdbtietz yahoo com>:
I am creating two widget subclasses, one which is a
subclass of GtkContainer and one which is a subclass of
GtkButton.  Both need to receive the enter-notify signal. 
I can successfully obtain the enter-notify signal fot
GtkButton in my_button_subclass_init:

    g_gtk_button_mouse_enter_notify_event =
widget_class->enter_notify_event;
    widget_class->enter_notify_event =
my_button_subclass_enter_notify_event;

That function does get called, I do my thing, and then
call the GtkButton class version.  When I try to do the
same thing for my GtkContainer subclass though, it doesn't
happen.  I more or less understand this: my GtkContainer
subclass is GTK_NO_WINDOW, and according to the Gtk docs I
need to put it inside of a GtkEventBox.  Fair enough.  But
I am studying gtkbutton.c so see how to do this right and to
copy its methodology, and it isn't creating GtkEventBox.  I
found a clue in gtk_button_realize: it's calling
gdk_window_new, so it seems that GtkButton has its own
GdkWindow, which would explain why it received enter-notify
events.  Fair enough.  Here's the weird part though.  I
found that GtkButton has the GTK_NO_WINDOW flag set!  Any
help in understanding these behaviors and observations would
be appreciated.

You need to call gtk_widget_add_events() on your widget and
add the
event GDK_ENTER_NOTIFY_MASK.

  http://library.gnome.org/devel/gtk/stable/GtkWidget.html#gtk-widget-add-events
  http://library.gnome.org/devel/gdk/2.22/gdk-Events.html#GdkEventMask


HTH
Kind Regards
-- 
Mike







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