Re: Removing key-presses from queue in "key-press-even"
- From: Havoc Pennington <hp redhat com>
- To: Janus "N." Tøndering <j nus person dk>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Removing key-presses from queue in "key-press-even"
- Date: 15 Jun 2001 00:51:10 -0400
Janus "N." Tøndering <j nus person dk> writes:
I am rather new to the GTK+ toolkit (been a windows programmer) and I've
run into a small problem that I cannot find the answer to in the GTK
reference.
I have an application with a gtk_entry and I have a "key-press-event".
Now I want to capture an GDK_KEY_Up event and do some text stuff. My
problem now is that the focus should stay on the gtk_entry and not
change.
How do I stop the GDK_KEY_Up from being processed further?
You need to return TRUE from the *emission* of key_press_event on the
entry.
By emission, I don't mean signal handler, but rather the invocation of
the entire handler list. A handler list looks like:
1. Handlers connected with gtk_signal_connect() in
connection order
2. Default handler
3. Handlers connected with gtk_signal_connect_after()
in connection order
The return value of the emission is the return value of the last
handler that runs.
Since GtkEntry has a default handler, to change this return value you
have to connect a handler with gtk_signal_connect_after().
In that handler, return TRUE. Then the event won't be propagated to
other widgets.
Alternatively, you can use plain gtk_signal_connect(), and call
gtk_signal_emit_stop_by_name() in your handler if the pressed key is
GDK_Up. This stops the emission, guaranteeing that you are the last
handler to run, and thus you get to determine the return value by
returning TRUE.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]