Module: CWM::ItemsSelection

Included in:
ComboBox, MenuButton, MultiSelectionBox, RadioButtons, SelectionBox
Defined in:
library/cwm/src/lib/cwm/common_widgets.rb

Overview

A mix-in to define items used by widgets that offer a selection from a list of values.

Instance Method Summary collapse

Instance Method Details

#change_items(items_list) ⇒ void

This method returns an undefined value.

Change the list of items offered in widget. The format is the same as in #items

Parameters:

  • items_list (Array<Array(String,String)>)

    new items



71
72
73
74
75
# File 'library/cwm/src/lib/cwm/common_widgets.rb', line 71

def change_items(items_list)
  val = items_list.map { |i| Item(Id(i[0]), i[1]) }

  Yast::UI.ChangeWidget(Id(widget_id), :Items, val)
end

#cwm_definitionWidgetHash

Returns:



61
62
63
64
65
# File 'library/cwm/src/lib/cwm/common_widgets.rb', line 61

def cwm_definition
  super.merge(
    "items" => items
  )
end

#itemsArray<Array(String,String)>

Items are defined as a list of pairs, where the first one is the ID and the second one is the user visible value

Examples:

items method in widget

def items
  [
    [ "Canada", _("Canada")],
    [ "USA", _("United States of America")],
    [ "North Pole", _("Really cold place")],
  ]
end

Returns:

  • (Array<Array(String,String)>)


56
57
58
# File 'library/cwm/src/lib/cwm/common_widgets.rb', line 56

def items
  []
end