On Fri, 2009-09-11 at 12:23 +0200, Joerg Anders wrote:
> gboolean key_press_handler(GtkWidget *widget, GdkEventKey *event, gpointer data) {
> gtk_im_context_filter_keypress(im_context, event);
> return FALSE;
> }
...
> g_signal_connect (the_window, "key-press-event", G_CALLBACK (key_press_handler), NULL);
You need to inhibit the event from continuing to propagate if the input
method handled the keystroke, ie:
static gboolean
keystroke_cb
(
GtkWidget* widget,
GdkEventKey* event,
gpointer user_data
)
{
GtkIMContext* im;
im = (GtkIMContext*) user_data;
if (gtk_im_context_filter_keypress(im, event)) {
return TRUE;
}
return FALSE;
}
...
You also need¹ to hookup an identical handler (reuse the same one, hey)
to "key-release-event", so for:
im = gtk_im_context_simple_new();
and some GtkWidget, say a GtkDrawingArea, you can do:
g_signal_connect(widget, "key-press-event", G_CALLBACK(keystroke_cb), im);
g_signal_connect(widget, "key-release-event", G_CALLBACK(keystroke_cb), im);
AfC
Sydney
¹ At least, this is what I found if I wanted the default (aka
GtkIMContextSimple, ie the one that handles Compose sequences) input
method to work, depending on whether you held the <Compose> or
<Ctrl><Shift>[+<u>] keys down or not.
--
Andrew Frederick Cowie
Operational Dynamics is an operations and engineering consultancy
focusing on IT strategy, organizational architecture, systems
review, and effective procedures for change management: enabling
successful deployment of mission critical information technology in
enterprises, worldwide.
http://www.operationaldynamics.com/
Sydney New York Toronto London
Attachment:
signature.asc
Description: This is a digitally signed message part