Selection behavior for Fl_Check_Browser?

12 views
Skip to first unread message

Tony

unread,
May 7, 2023, 12:46:13 PM5/7/23
to fltk.general
Hi all,

Reading the docs for Fl_Check_Browser, it states that "The Fl_Check_Browser widget displays a scrolling list of text lines that may be selected and/or checked by the user." However, I see no mechanism to select (not check) lines in the browser: it looks like selection is determined by cb_item->selected, but nothing ever sets this to 1.

How can I get line selection behavior in Fl_Check_Browser?

Thanks,
Tony

Matthias Melcher

unread,
May 7, 2023, 1:08:48 PM5/7/23
to fltk.general
I don't think you can select an item in the check browser in the classical sense. Fl_Check_Browser::value will return the last item that was clicked IIRC. Apart from that, the check button is the significant piece here.

Tony

unread,
May 7, 2023, 1:14:31 PM5/7/23
to fltk.general
Thanks for your reply! That's unfortunate :(

Is there a way to have a widget that does combine these two behaviors together?

imm

unread,
May 7, 2023, 1:35:02 PM5/7/23
to General FLTK
(Top posting, sorry. I'm on my phone...)

If set_checked() isn't what you want (and it sounds like it is not!) then I guess I always assumed the stock behaviour of the base widget would do that - but since you're asking I'm guessing it does not.

Erco has a neat demo of making a widget browser on his Cheat Sheet; it would be feasible to tweak that to hold lines of text with check boxes then add selection handling to suit your needs, I reckon.

Other than that... I got nothing...

--
Ian
From my Fairphone FP3
   

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/229039fa-fa3f-4858-b95d-cb9ab5af967cn%40googlegroups.com.

Matthias Melcher

unread,
May 7, 2023, 1:39:57 PM5/7/23
to fltk.general
As Ian says, you can still use item_select() and item_selected() form the super class.

Tony

unread,
May 7, 2023, 1:40:39 PM5/7/23
to fltk.general
Thanks for the pointer, I'll take a look!

Greg Ercolano

unread,
May 7, 2023, 1:51:44 PM5/7/23
to fltkg...@googlegroups.com
    I just woke up, so maybe I'm not seeing this correctly, but maybe to select items
    you just want to use one of the other Fl_Xxx_Browser classes instead:

        Fl_Hold_Browser
        Fl_Select_Browser
        Fl_Multi_Browser

    Fl_Multi_Browser is the one I use most often.

    You can test all the variations by running the test/browser demo, and changing the
    little pulldown at the lower right that says 'Multi' on startup. It can be changed to
    the different browser types.
Reply all
Reply to author
Forward
0 new messages