Re: Can A Drawable Canvas Receive Key Events?



Mike Melanson wrote:
I found that when I put a big text widget inside the XEmbed'ed GtkPlug container instead of a big drawable canvas, it was able to receive focus. Digging into the GTK source code, I noticed that it calls gtk_widget_grab_focus() when it receives a button press event. So I did the same for my canvas widget when the user clicks in it, and it seems to work. The widget retains focus until the user clicks outside of the window.

I missed a crucial step here. You also need to specify that the ordinarily non-focusable widget can receive focus by setting its "can-focus" property:

  GTK_WIDGET_SET_FLAGS (GTK_WIDGET(my_widget), GTK_CAN_FOCUS);

--
        -Mike Melanson



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