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



79
80
81
82
83
# File 'library/cwm/src/lib/cwm/common_widgets.rb', line 79

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:



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

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)>)


64
65
66
# File 'library/cwm/src/lib/cwm/common_widgets.rb', line 64

def items
  []
end