Class: Wx::PersistentRadioButton

Inherits:
PersistentWindow
  • Object
show all
Defined in:
lib/wx/doc/gen/persistent_window.rb

Overview

Persistence adapter for RadioButton controls.

This adapter saves and restores the index of the selected RadioButton in a group of radio buttons, to allow to retain the selection across program executions. Example of using it:

// Assume that all these controls are added to some sizer elsewhere.
  auto* label = new wxStaticText(this, wxID_ANY, "Play with:");
  
  auto* black = new wxRadioButton(this, wxID_ANY, "&Black",
                                  wxDefaultPosition,
                                  wxDefaultSize,
                                  wxRB_GROUP);
  auto* white = new wxRadioButton(this, wxID_ANY, "&White");
  
  // We register the first radio button here, but all radio buttons in the
  // same group are potentially affected by this call.
  wxPersistentRegisterAndRestore(black);

During the first program execution, black colour will be selected, but if the user selects white pieces, this selection will be restored during the subsequent run.

Requires:

  • USE_CONFIG

Instance Method Summary collapse

Constructor Details

#initialize(radiobutton) ⇒ Wx::PersistentRadioButton

Constructor.

Please note that the radio button must be the first one in the group, i.e. have RB_GROUP style set, otherwise an assertion will be triggered. Also note that currently RB_SINGLE style is not supported.

Parameters:



224
# File 'lib/wx/doc/gen/persistent_window.rb', line 224

def initialize(radiobutton) end

Instance Method Details

#restoreBoolean

Restore the previously saved selection.

If the saved index is valid, i.e. is positive and less than the number of radio buttons in the group, the radio button with the corresponding index will be selected.

Returns:

  • (Boolean)


236
# File 'lib/wx/doc/gen/persistent_window.rb', line 236

def restore; end

#savevoid

This method returns an undefined value.

Save the currently selected button index.

The 0-based index of the selected radio button in the group is saved as radio button value.



230
# File 'lib/wx/doc/gen/persistent_window.rb', line 230

def save; end