Frage

I'm working on a gtk UI for an IRC client. I'd like to add the following interaction to it:

  1. On user input: /join #channel
  2. Create a new tab < -- Working
  3. Set focus on it < -- Not working

I Can't seem to set the focus (not the input focus, the view focus like sttign the widget to be the active view) on the created GtkWidget* on my notebook. I tried using the grab_focus() function but the focus is still on the is created tab.

What am I missing?

War es hilfreich?

Lösung

The widget has to be focusable (gtk_widget_can_focus), otherwise gtk_widget_grab_focus will not do anything.


Also there is no such thing as "view-focus". You have the input focus and the window focus.

  • window focus - makes your application receive mouse/keyboard events.
  • widget input focus - makes your widget receive keyboard events if the window is focussed

Note that input here means input event (a GtkButton usually only handles the Enter whereas a GtkScale handles 0123...9.+- and may handle the Enter as well).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top