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).