Get value of radio group on C++

703 views Asked by At

I'm using C++ to create a GLUI window. I have a radio button, and I am trying to get the two options I have to have different callbacks.

For now, this is my code:

radio = glui->add_radiogroup_to_panel(panel_1, NULL,
                                      RADIOBUTTON_ID,control_cb);
glui->add_radiobutton_to_group( radio, "Choice1");
glui->add_radiobutton_to_group( radio, "Choice2");

I am trying to get the value of the radio group, either 0 or 1, to then pass an if loop to control_cb

case RADIOBUTTON_ID:
    int choice = /*value of radiobutton*/
    if (choice == 0) printf("Hello");
    else printf("world");

The question is, how to get that value for int choice?

Thank you!

1

There are 1 answers

0
Hatted Rooster On BEST ANSWER

Use the RadioGroup method get_int_val():

int choice = radio->get_int_val();