On 14.11.2010, at 16:43, jseb wrote:
> I'm using this version of fltk: 2.0_pre6970 (got from Gentoo's portage)
> 
> I've got a strange behaviour when getting text lines from a browser widget.
> I don't get the text of currently selected line in the browser, but i 
> get random lines (which belong too to the browser).
> 
> Here is the only way i've found to get the correct selected line:
> 
> (with fltk::Browser *browser pointing on a valid Browser class, of course)
> 
>   int value = browser->value(); //get the number of selected line
>   browser->select(value); //go to the selected line (!!!)
> 
>   fltk::Widget *selected = browser->item();
>   if (selected) {
>     fprintf(stderr,"selection: %s\n", selected->label() );
>   }
> 
> 
> That seems a bit crazy, but if i don't use "browser->select" for 
> selecting the already selected line, the later 
> "(browser->item())->label()" won't return the correct line.

Well, the documentation says:

"The "current item". In callbacks this is the item the user clicked on. 
Otherwise you probably can't make any assumptions about it's value."

So unless you do this in a callback, item() will not return anything useful.

You either need to walk the widget tree and search for someWidget->selected(), 
or you set a callback for each entry.

But I am no 2.0 expert... .
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to