On 28.04.2011 14:01, Paul R wrote:
> The group will only contain check buttons, given this is it safe to
> do this?
>
> for (int i=0; i< group->children(); i++)
> {
> Fl_Widget *w = group->child(i);
> Fl_Check_Button* b = (Fl_Check_Button*)w;
> if (b)
you wouldn't need this for a static cast like that above (KISS).
> {
> char v = b->value();
> if(v = 1)
Oops, that should be "if (v==1)", of course ;-)
but I'd prefer "if (v != 0), if at all.
> {
> //it's selected
> }
> }
> }
>
> I know that asking if v = 1 is pretty ropey here but the docs say
> value returns a char for check_button->value() and when i tried
> asking for the char value like '1' it does not equate to one.
No, that would be wrong, it's a pure binary 1 (or 0).
> Equally the test using int v was not working.
> I only need to know if it is selected.
if (b->value()) { // it's selected };
But any int or char variable should get converted automatically,
unless you use ASCII values like '1' for comparison.
> There are rather a lot of the boxes so i would not name each one
> unless it becomes neccesary, I may create them at runtime even
> using an array.
Yes, that's what I meant. No need to use individual names, but if
you have an array of your check boxes (I assume pointers) anyway,
then you can iterate through the array and don't need to find and
check Fl_Group's children at all...
Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk