Re: [gedit-list] Capturing key-press-event



On 01/17/2011 04:56 AM, Ishan Jayawardena wrote:
Hi,
I was trying to capture key stroke events from the gedit window. To do
that, I wrote a call back function and tried to connect it to the
"key-press-event" of GeditView, inside the gedit_view_init() method in
gedit-view.c,

       g_signal_connect (view,
                                  "key-press-event",
                                  G_CALLBACK (gedit_myac_key_press_event),
                                  NULL);

and the call back function has the following prototype.

       gboolean gedit_myac_key_press_event(GeditView *view, GdkEventKey
* event, gpointer data);

But this produces a segmentation fault when run. I cannot identiyfy
the error.
Try running gedit in gdb and see where it crashes. The signal connection seems fine to me, maybe it just crashes in your function?

You can also try to use python instead of C.


Jesse
  I tried connecting the signal from within GeditDocument and
GeditWindow the same way, but they all gave the same error. What I
expected was since both GeditWindow and GeditView derive from
GtkWidget, I would be able to connect my call back function to
GtkWidget's "key-press-event". But this was not successful. Can you
tell me what my method is not working? How can I correctly capture key
stroke events?

Thank you.



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