Re: EventBox's focus




NGUYEN <htn3463@osfmail.isc.rit.edu> writes:

> First of all, thanks for your help(You rock!..:)). The event
> handling works right. Unfortunately, it turned out that setting
> GTK_STATE_PRELIGHT makes no difference on the event widget( thats if
> i didnt goof off but i'm sure , i didnt). So let me brief you on
> what i'm trying to accomplish here. I use the eventbox to draw a
> pixmap on that acts like a button(this is for a toolbar). The reason
> i want this is because, I do not want the border around the pixmap
> if I was to pack it in a button(or use GtkToolbar) . So I thougth if
> i'll leave a border_width around this pixmap then set_state to get
> that PRELIGHT state when the mouse is moved over. It didnt work. I
> also tested drawing a label onto the eventbox and set the eventbox
> PRELIGHT, still didnt work.  I realize I could just use two pixmaps
> and switch back and forth. Do you have any suggestions?. Thanks in
> advance.

Hmmm. Probably a bug in the EventBox (it should change its background
to match the background of the current style but doesn't).

Here's a workaround:

void
state_changed (GtkWidget *widget, gpointer data)
{
  if (GTK_WIDGET_REALIZED (widget))
    gtk_style_set_background (widget->style, widget->window, widget->state);

  if (GTK_WIDGET_DRAWABLE (widget))
    gdk_window_clear_area (widget->window, 0, 0,
			   widget->allocation.width, widget->allocation.height);
}

gtk_signal_connect (GTK_OBJECT(event_box), "state_changed",
  		    GTK_SIGNAL_FUNC (state_changed), NULL);
    
Regards,
                                        Owen






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