Re: ListBox



Nicolas Raitman wrote:

Hi to all! Suppose I have a ListBox and the user selects an item. How can I
find which item the user selected, I mean, is there a function list
gtk_list_get_item?? Something like this??
Thanks a lot,
Nicolas

NOTE: I'm assuming you're talking about a GtkCList.  If not, ignore the
rest of this message.

You'd think such a function would exist, but when I needed the same
thing, I couldn't find one.  I did the following:

void clist_select_row_callback(GtkWidget* clist, gint row, gint column,
                    GdkEventButton* event, gpointer data)
{
...
    /* there is no "get current selection" function for the clist.
       the OK button needs to know the current selection, add it
       as user data to the clist */
    gtk_object_set_user_data(GTK_OBJECT(clist), (gpointer)row);
...
}

and when I needed the row number:

    row = (gint)gtk_object_get_user_data(GTK_OBJECT(data));

I'd love to know if there was a better way to handle this!




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