Gtk_widget_has_focus on a GtkComboBoxText

I am trying to use gtk_widget_has_focus on a GtkComboBoxText but it never seems to return anything but 0 (never focused).

The widget is created without an entry.

Is there some child or parent that actually has focus? I can get a callback for the focus event signals entry & leave indicating that the widget is getting focus (beyond just seeing it on the screen)

edit … this seems to work but I don’t know why!

    gboolean bFocused = gtk_widget_has_focus(
            gtk_widget_get_first_child( gtk_widget_get_first_child( GTK_WIDGET( wComboBoxText ) ) ) );

Hi,

The way I use is to get the focused widget of the toplevel, and check if it’s inside the combobox:

focused_widget = gtk_window_get_focus (window);
bFocused = focused_widget && gtk_widget_is_ancestor (focused_widget, wComboBoxText);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.