Re: How to handle events on arrow widget




xsj@cmbchina.com (Xiong Shao Jun) writes:

> Hi, gtk fans, I ran into a problem a few days ago. I'd like to handle
> events on an arrow
> widget. I used the following program segment:
> butbox = gtk_vbox_new(FALSE, 0);
> ......
> arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_OUT);
> gtk_box_pack_start(GTK_BOX(butbox), arrow, TRUE, TRUE, 0);
> gtk_widget_show(arrow);
> 
> gtk_signal_connect(GTK_OBJECT(arrow),  "button_press_event",
>         (GtkSignalFunc)arrow_button,
>         NULL);
> gtk_signal_connect(GTK_OBJECT(arrow),  "enter_notify_event",
>         (GtkSignalFunc)arrow_enter,
>         NULL);
> gtk_signal_connect(GTK_OBJECT(arrow),  "key_press_event",
>         (GtkSignalFunc)arrow_key,
>         NULL);
> gtk_widget_set_events(arrow,   GDK_BUTTON_PRESS_MASK |
>                                                 GDK_KEY_PRESS_MASK |
>                                                 GDK_ENTER_NOTIFY_MASK);
> 
> But the event handlers are not called. So how to handle events on
> arrows? Should I have
> to use event box, and pack the arrow into the event box, then handle
> events on event box?

Yes, you need an eventbox. Only widgets with windows can get
events. And arrow widgets don't have windows.

Regards,
                                        Owen



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