Name

RadioButton — Clickable on/off toggle button for radio boxes

Synopsis

RadioButton ( string label ,
  boolean selected );
 

Parameters

string label

Options

boldFont

use a bold font

Optional Arguments

boolean selected

Description

A radio button is not usefull alone. Radio buttons are group such that the user can select one radio button of a group. It is much like a selection box, but radio buttons can be dispersed over the dialog. Radio buttons must be contained in a RadioButtonGroup.

Usage

 	`RadioButton( `id( `now ), "Crash now", true )

Examples

          {
    UI::OpenDialog(
	       `RadioButtonGroup(`id(`rb), 
				 `VBox(
				       `Label("How do you want to crash?"),
				       `Left(`RadioButton(`id(0), "No&w")),
				       `Left(`RadioButton(`id(1), "&Every now and then" )),
				       `Left(`RadioButton(`id(2), "Every &five minutes", true)),
				       `Left(`RadioButton(`id(3), `opt(`boldFont), "Ne&ver", true )),
				       `HBox(
					     `PushButton(`id(`next), "&Next"),
					     `PushButton("&OK")
					     )
				       )
				 )
	       );
    
    while (true)
    {
	any ret = UI::UserInput();
	if (ret == `next)
	{
	    integer current = (integer) UI::QueryWidget(`id(`rb), `CurrentButton);
	    current = (current + 1) % 4;
	    UI::ChangeWidget(`id(`rb), `CurrentButton, current);
	}
	else break;
    }
    
    UI::CloseDialog();
}

					      

        
          {
    UI::OpenDialog(
	       `RadioButtonGroup(`id(`rb), 
				 `VBox(
				       `Label("How do you want to crash?"),
				       `Left(`RadioButton(`id(0), `opt(`notify), "No&w")),
				       `Left(`RadioButton(`id(1), `opt(`notify), "&Every now an then" )),
				       `Left(`RadioButton(`id(2), `opt(`notify), "Every &five minutes")),
				       `Left(`RadioButton(`id(3), `opt(`notify), "Ne&ver", true )),
				       `HBox(
					     `PushButton(`id(`next),  "&Next"),
					     `PushButton(`id(`close), "&Close")
					     )
				       )
				 )
	       );
    
    while (true)
    {
	any ret = UI::UserInput();

	if ( ret == `close ) break;
	else if (ret == `next)
	{
	    // y2milestone("Hit next");
	    integer current = (integer) UI::QueryWidget(`id(`rb), `CurrentButton);
	    current = (current + 1) % 4;
	    UI::ChangeWidget(`id(`rb), `CurrentButton, current);
	}
	else
	{
	    y2milestone("Hit RadioButton #%1", ret);
	}
    }

    y2milestone("Terminating.");
    
    UI::CloseDialog();
}

					      

        
          {
    UI::OpenDialog( `VBox(
		      `Frame ( "CPU &Speed",
			       `RadioButtonGroup(
						 `VBox(
						       `Left(`RadioButton("Normal"	)),
						       `Left(`RadioButton("Overclocked"	)),
						       `Left(`RadioButton("Red Hot"	)),
						       `Left(`RadioButton("Melting", true ))
						       )
						 )
			       ),
		      `PushButton("&OK")
		      )
		);
    UI::UserInput();
    UI::CloseDialog();
}

        
          {
    // Demo for shortcut checking:
    // Deliberately generate a shortcut conflict.

    UI::OpenDialog(
	       `VBox(
		     `RadioButtonGroup(
				       `VBox(
					     `Left( `RadioButton( "Instant &Play", true ) ),
					     `Left( `RadioButton( "Demo &Only" ) )
					     )
				       ),
		     `Left( `ComboBox( "Game &Type:",
				       [ "Boring", "Full automatic", "Unplayable" ] ) ),
		     `InputField( "Nickname for &Player 1:" ),
		     `InputField( "Nickname for &Player 2:" ),
		     `IntField( "Maximum &Time:", 0, 100, 20 ),
		     
		     `PushButton( "&OK" )
		     )
	       );

    UI::UserInput();
    UI::CloseDialog();
}