Re: Can A Drawable Canvas Receive Key Events?



Mike Melanson wrote:
Tristan Van Berkom wrote:
Did you add the events to the event mask before the widget was
realized ?

Does the widget in question have keyboard focus at the time
you want to recieve the keyboard events ?

Is the widget in question marked to be focus-capable ?
(i.e. the can-focus bit/property)

This last item did the trick. I set the can-focus property and the GtkDrawingArea now registers key presses and releases. Thanks.

Now that it works in the contrived standalone app, I need to figure out how to get key events in an XEmbed'ed application. I apply the same can-focus property change but I'm afraid I might be fighting with the hosting app for the key events.

Answering my own question since I know there are interested people out there...

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.

Wow, I can't believe that looking at the source actually helped. :)

--
        -Mike Melanson



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