Class: Wx::PersistentComboBox

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

Overview

Persistence adapter for ComboBox.

This adapter saves and restores the items of ComboBox. A persistent combobox can be used to preserve history of user entries. Example of using it:

# Suppose you need to ask the user to select their favourite Linux
  # distribution, for some reason:
  combo = Wx::ComboBox.new(self, Wx::ID_ANY)
  unless Wx.persistent_register_and_restore(combo, 'distribution')
    # Seed it with some default contents.
    combo.append("Debian")
    combo.append("Fedora")
    combo.append("Ubuntu")
  end
  
  # Optionally, you might want to restore the last used entry:
  combo.set_selection(0)

Requires:

  • USE_CONFIG

Instance Method Summary collapse

Constructor Details

#initialize(combobox) ⇒ Wx::PersistentComboBox

Constructor.

Parameters:



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

def initialize(combobox) end

Instance Method Details

#restoreBoolean

Restore the combobox items.

This function doesn’t change the current combobox value, you need to call SetSelection(0) explicitly, after verifying that the combobox is not empty using its IsListEmpty() method, if you want to restore the last used value automatically. Otherwise the user can always do it by opening the combobox and selecting it manually.

Returns:

  • (Boolean)


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

def restore; end

#savevoid

This method returns an undefined value.

Save the current items and value.

The current control value is saved as the first item, so that calling SetSelection(0) when the control is created the next time will restore the value which was last used. If the current value is the same as one of the existing items, this item is moved to the front of the list, instead of being added again. If the current value is empty, it is not saved at all. At most 10 items are saved, if the combobox has more than 10 items, or exactly 10 items and the current value is different from all of them, the items beyond the tenth one are discarded.



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

def save; end