Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'll paste a summary of how gtk_window_key_press_event() works:</p> <pre><code>gboolean gtk_window_propagate_key_event (GtkWindow *window, GdkEventKey *event) { gboolean handled = FALSE; focus = window-&gt;focus_widget; while (!handled) { GtkWidget *parent; handled = gtk_widget_event (focus, event); focus = gtk_widget_get_parent (focus); } return handled; } static gint gtk_window_key_press_event (GtkWidget *widget, GdkEventKey *event) { GtkWindow *window = GTK_WINDOW (widget); gboolean handled = FALSE; /* handle mnemonics and accelerators */ if (!handled) handled = gtk_window_activate_key (window, event); /* handle focus widget key events */ if (!handled) handled = gtk_window_propagate_key_event (window, event); /* Chain up, invokes binding set */ if (!handled) handled = GTK_WIDGET_CLASS (gtk_window_parent_class)-&gt;key_press_event (widget, event); return handled; } </code></pre> <p>This basically means:</p> <ol> <li><p>See if the key is appropriate for a mnemonic (i.e. labels that have underlines) or an accelerator (from GtkAccelGroup).</p></li> <li><p>Starting from the focused widget and going up the container hierarchy, see if some widget handles the keypress.</p></li> <li><p>Pass on the keypress to the parent class of GtkWindow. The closest parent that handles that is GtkWidget, and it does so by dealing with bindings (from gtk_binding_entry_add()).</p></li> </ol> <p>As you said, simply doing g_signal_connect() to the key-press-event signal of GtkWindow will give you <em>all</em> keypresses that happen when that window is focused.</p> <p>Try doing g_signal_connect_after() instead. This will effectively add another fallback to the sequence above - it means, "run my signal handler after the default one". Note that you'll be catching <em>all</em> unhandled keypresses (e.g. if someone presses a function key that your app doesn't handle), so don't assume that the only thing that gets through to your handler is coming from your barcode scanner.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload