Re: [gtk-list] Event propogation problem
- From: Owen Taylor <otaylor redhat com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Event propogation problem
- Date: 20 Jan 2000 14:03:16 -0500
Ian Britten <britten@universal.ca> writes:
> Hi all,
> I'm having some problems with (key) events being propagated when I don't
> think they should be. I have two specific cases that both seem to show
> the same sort of problem.
>
> The first case is from Havocs FAQ
> (http://developer.gnome.org/doc/GGAD/faqs.html), regarding the use of the
> arrow keys ("I want to use the arrow keys as a control ...")
> The FAQ describes how the event is dispatched to the focus widget, and
> if its signal handler returns TRUE, then the event will not be propagated.
> This is what I'm doing in my code, but the focus widget is changed
> anyways, indicating that the event did, in fact, propogate to the toplevel
> GtkWindow.
Three different sets of handlers are run for each signal emission:
- handlers connected with gtk_signal_connect()
- the default handler for the widget
- handlers connected with gtk_signal_connect_after()
Only the _last_ return value matters. The default handlers is running
after your signal handler and returning FALSE.
So you have two choices:
- If you want to override the default handler, use gtk_signal_connect(),
and then call gtk_signal_emit_stop_by_name() before returning TRUE
- If you want to supplement the default handler use gtk_signal_connect_after().
Havoc says he covers this in the section signal emission in his book.
> In the second case, I have a key snooper installed
> (gtk_key_snooper_install()), looking for the Escape key. However, in my
> application, this sniffer should only be looking for the key if nothing
> else has responded to the key. This is handled in my code via the signal
> handler callback. If it responded to the key, the callback will return
> true, indicating that the event should not be propaged any further.
> However, even though I do return TRUE, the sniffer callback is called
> anyways.
Key snoopers are called before any other handling of the key press. They
really aren't intended for general use - perhaps you want an accelerator
instead. (Or simply want to connect to ::key_press_event on the toplevel.)
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]