Select only one button?

19 views
Skip to first unread message

supsm17

unread,
Jun 22, 2021, 1:10:44 PM6/22/21
to fltk.general
Is it possible to select only 1 button in a scroll? (i.e. when one button gets selected, the previous one gets deselected). I thought of clearing the scroll entirely and re-adding each of the widgets, but is there a better way?

imm

unread,
Jun 22, 2021, 1:15:29 PM6/22/21
to General FLTK
On Tue, 22 Jun 2021, 18:10 supsm17 wrote:
Is it possible to select only 1 button in a scroll? (i.e. when one button gets selected, the previous one gets deselected). I thought of clearing the scroll entirely and re-adding each of the widgets, but is there a better way?


Check the docs for setting the button type to a "radio button" - that's the button mode that acts as you described.

--
Ian
From my Fairphone FP3
  

supsm17

unread,
Jun 22, 2021, 2:11:10 PM6/22/21
to fltk.general
Thanks

supsm17

unread,
Jun 23, 2021, 1:14:24 PM6/23/21
to fltk.general
Is it possible to get the currently selected button, or do I have to do that manually with callbacks?

imm

unread,
Jun 23, 2021, 1:30:25 PM6/23/21
to General FLTK
On Wed, 23 Jun 2021, 18:14 supsm17 wrote:
Is it possible to get the currently selected button, or do I have to do that manually with callbacks?

There's a couple of ways to get that.
Individual callbacks is certainly one way. 
Or you can store your buttons in an array then poll the array to see which is set.
What I usually do is have the buttons share a callback (the user data id's each button) and store the last selected ID for easy access.
But there's myriad other ways, which may well be better!
Reply all
Reply to author
Forward
0 new messages