Re: Insensitive buttons
- From: Wolfgang Sourdeau <wolfgang contre com>
- To: Havoc Pennington <hp redhat com>
- Cc: "'gtk-app-devel-list gnome org'" <gtk-app-devel-list gnome org>
- Subject: Re: Insensitive buttons
- Date: Mon, 28 May 2001 23:57:10 -0400
There's a special hack in gtk_main_do_event().
One think I have noticed is that when an insensitive widget has its
event mask not set to catch button_press events, those events are sent
to his parent. Is that the hack you are talking about ?
This is the method I have found and which solves my problem. Maybe
there is a better way ? I will look at gtk_main_do_event.
Btw, I think I have found a bug but I can't place it. Whenever a
widget has its button_press_mask deactivated, gdk_window_get_events
still returns it although it has no effect on the widget itself.
My function used to be sth like this (not exactly, but for the most):
static void
usr_btn_state_changed_cb (GtkWidget *button,
GtkStateType state, gpointer data)
{
GdkEventMask event_mask, condition;
event_mask = gdk_window_get_events (button->window);
condition = (event_mask & GDK_BUTTON_PRESS_MASK);
if (GTK_WIDGET_IS_SENSITIVE (button))
{
if (condition)
event_mask &= ~GDK_BUTTON_PRESS_MASK;
}
else
if (!condition)
event_mask != GDK_BUTTON_PRESS_MASK;
gdk_window_set_events (button->window, event_mask);
}
it did work to remove the button_press_mask (case 1) but since
(condition) was always true, the mask was never put back and so my
buttons were still insensitive to mouse clicks although they were
reported as sensitive.
My function now looks like this:
static void
usr_btn_state_changed_cb (GtkWidget *button,
GtkStateType state, gpointer data)
{
GdkEventMask event_mask;
event_mask = gdk_window_get_events (button->window);
if (GTK_WIDGET_IS_SENSITIVE (button))
event_mask |= GDK_BUTTON_PRESS_MASK;
else
event_mask &= ~GDK_BUTTON_PRESS_MASK;
gdk_window_set_events (button->window, event_mask);
}
...which works all the time.
Wolfgang
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]