FAQ Index - Search - Recent Changes - Everything - Add entry

<< Previous Entry | FAQ Entry 3.11 | Next Entry >>

3.11. How do signals and events propagate in GTK+?

Though there is a section on this in the GTK+ tutorial at [www.gtk.org] it doesn't clearly describe the difference in propagation behaviour between simple signals, events and keyboard events. James offers a more complete answer:

A single signal emission will only call handlers attached to the object it was emitted on. The propagation of events up the heirachy is acheived by emitting the signal a number of times.

For events such as the button presses and motion events, the event is delivered first to the widget the event occurred in. It will emit the appropriate event signal. If the event signal returns false (indicating that the event hasn't been handled), then a signal will be emitted on the parent. This continues all the way up to the toplevel if no one handles the event.

Keyboard events are handled differently. When your window receives a keyboard event, it is first dispatched to the toplevel window, which will check if it matches any keyboard shortcuts. If the key press doesn't match a shortcut, then the event is dispatched to the child widget that currently has focus.

PyGTK FAQ Wizard | PyGTK Homepage | Feedback to faq at pygtk.org