Class: CWM::RadioButtons

Inherits:
AbstractWidget show all
Includes:
ItemsSelection
Defined in:
library/cwm/src/lib/cwm/common_widgets.rb

Overview

Note:

if radio buttons are modified during runtime, like with #change_items then handle won't work correctly unless handle_all_events specified

A selection of a value via radio buttons. The AbstractWidget#label method is mandatory.

See Also:

  • for child example

Instance Attribute Summary

Attributes inherited from AbstractWidget

#handle_all_events, #widget_id

Instance Method Summary collapse

Methods included from ItemsSelection

#change_items, #items

Methods inherited from AbstractWidget

#cleanup, #disable, #displayed?, #enable, #enabled?, #focus, #fun_ref, #handle, #help, #init, #label, #my_event?, #opt, #refresh_help, #store, #validate, widget_type=

Instance Method Details

#cwm_definitionWidgetHash

See AbstractWidget#cwm_definition In addition to the base definition, this honors possible vspacing and hspacing methods

Examples:

defining additional space between the options

def vspacing
  1
end

defining some margin at both sides of the list of options

def hspacing
  3
end

Returns:



345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'library/cwm/src/lib/cwm/common_widgets.rb', line 345

def cwm_definition
  additional = {}
  additional["vspacing"] = vspacing if respond_to?(:vspacing)
  additional["hspacing"] = hspacing if respond_to?(:hspacing)
  # handle_events are by default widget_id, but in radio buttons, events are
  # in fact single RadioButton
  if !handle_all_events
    event_ids = items.map(&:first)
    additional["handle_events"] = event_ids
  end

  super.merge(additional)
end

#hspacingFixnum

Returns margin at both sides of the options list.

Returns:

  • (Fixnum)

    margin at both sides of the options list



# File 'library/cwm/src/lib/cwm/common_widgets.rb', line 311

#valueObject

Get widget value

Calling this method only make sense when the widget is displayed (see #displayed?).



318
319
320
# File 'library/cwm/src/lib/cwm/common_widgets.rb', line 318

def value
  Yast::UI.QueryWidget(Id(widget_id), :CurrentButton)
end

#value=(val) ⇒ Object

Set widget value

Calling this method only make sense when the widget is displayed (see #displayed?).

Parameters:

  • val (Object)

    a value according to specific widget type



327
328
329
# File 'library/cwm/src/lib/cwm/common_widgets.rb', line 327

def value=(val)
  Yast::UI.ChangeWidget(Id(widget_id), :CurrentButton, val)
end

#vspacingFixnum

Returns space between the options.

Returns:

  • (Fixnum)

    space between the options



# File 'library/cwm/src/lib/cwm/common_widgets.rb', line 308