-
Notifications
You must be signed in to change notification settings - Fork 2
radiobutton
James Bremner edited this page Oct 19, 2019
·
1 revision
A widget where user can click to select one of a set of options.
// reference the windex gui framework
windex& W = windex::get();
// construct top level window
window& form = W.MakeWindow();
form.move({ 50,50,400,400});
form.text("A windex radiobutton");
// first group of radiobuttons
radiobutton& rb1 = W.make<radiobutton>(form);
rb1.first();
rb1.move( {20,20,100,30} );
rb1.text("Alpha");
radiobutton& rb2 = W.make<radiobutton>(form);
rb2.move( {20,60,100,30} );
rb2.text("Beta");
radiobutton& rb3 = W.make<radiobutton>(form);
rb3.move( {20,100,100,30} );
rb3.text("Gamma");
// second group of radio buttons
radiobutton& rb4 = W.make<radiobutton>(form);
rb4.first();
rb4.move( {150,20,100,30} );
rb4.text("X");
radiobutton& rb5 = W.make<radiobutton>(form);
rb5.move( {150,60,100,30} );
rb5.text("Y");
radiobutton& rb6 = W.make<radiobutton>(form);
rb6.move( {150,100,100,30} );
rb6.text("Z");
// display a button
button& btn = W.make<button>( form );
btn.move( {20, 150, 150, 30 } );
btn.text( "Show values entered" );
// popup a message box when button is clicked
// showing the values entered
btn.events().click([&]
{
std::string msg;
if( rb1.isChecked() )
msg = "Alpha";
else if( rb2.isChecked() )
msg = "Beta";
else if( rb3.isChecked() )
msg = "Gamma";
else
msg = "Nothing";
msg += " is checked";
msgbox(
form,
msg );
});
// show the application
form.show();
void move( const std::vector<int>& v )
locate and size. v specifies left, top, width, height in pixels
void text( const std::string& t )
specify text to be displayed
void first()
Make first radiobutton in a group
Clicking any radiobutton in a group will set that button and clear the other buttons in the group without effecting buttons in other groups.
This must be called for the first radiobutton of the first group if there will be more than one group.
This must be called before constructing the other buttons in the group.