GtkListBox selection oddities?



I have two separate GtkListBoxes which are identical in every way except
one is a list of labels while the other is a list of check buttons.

In the first list box, everything works exactly as expected.  A light
colored rectangle shows which row I am hovering over, and when I click on
that row, it gets highlighted blue.

In the second list box, I get the light colored rectangle as before, but
the blue highlighted item does not change when I click an entry in the list
(although the entry does toggle the check state).  Randomly (or so it
seems), clicking an entry will select it, but I have not been able to
reliably reproduce this to understand why.

In either case, using the keyboard to move the selection cursor works
perfectly.

I have reproduced this issue in a minimal sample (included below), compiled
against the latest available GTK3 version on Fedora 21.  How can I get the
same behavior with this list as I do when its just labels?

#include <gtk/gtk.h>

int main(int argc, char *argv[] )
{
    // Setup
    GtkWidget *window;
    gtk_init (&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);

    // Create List
    GtkWidget* list =  gtk_list_box_new ();
    GtkWidget* chk1 = gtk_check_button_new_with_label("One");
    GtkWidget* chk2 = gtk_check_button_new_with_label("Two");
    GtkWidget* chk3 = gtk_check_button_new_with_label("Three");
    GtkWidget* chk4 = gtk_check_button_new_with_label("Four");

    gtk_container_add(GTK_CONTAINER(list), chk1);
    gtk_container_add(GTK_CONTAINER(list), chk2);
    gtk_container_add(GTK_CONTAINER(list), chk3);
    gtk_container_add(GTK_CONTAINER(list), chk4);

    gtk_container_add(GTK_CONTAINER(window), list);

    // Show it all
    gtk_widget_show(GTK_WIDGET(chk1));
    gtk_widget_show(GTK_WIDGET(chk2));
    gtk_widget_show(GTK_WIDGET(chk3));
    gtk_widget_show(GTK_WIDGET(chk4));

    gtk_widget_show(GTK_WIDGET(list));
    gtk_widget_show  (window);
    gtk_main ();
    return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]