Class: Sirens::RadioButton
- Inherits:
-
PrimitiveComponent
- Object
- AbstractComponent
- PrimitiveComponent
- Sirens::RadioButton
- Defined in:
- lib/components/widgets/radio_button.rb
Instance Method Summary collapse
-
#click ⇒ Object
Actions.
-
#create_view ⇒ Object
Returns a ButtonView.
- #on_toggled(state:) ⇒ Object
-
#on_value_changed(announcement) ⇒ Object
Events.
Methods inherited from PrimitiveComponent
#apply_props, #initialize, #on_component_added, #on_model_changed, #populate_popup_menu, #set_props, #subscribe_to_model_events, #sync_ui_from_model
Methods inherited from AbstractComponent
#add_all_components, #add_component, #child_components, #default_model, #initialize, #model, #on_component_added, #on_model_changed, open, #props, #remove_component_at, #remove_last_component, #set_model, #set_props, #view
Constructor Details
This class inherits a constructor from Sirens::PrimitiveComponent
Instance Method Details
#click ⇒ Object
Actions
17 18 19 |
# File 'lib/components/widgets/radio_button.rb', line 17 def click() view.click end |
#create_view ⇒ Object
Returns a ButtonView.
6 7 8 9 10 11 12 13 |
# File 'lib/components/widgets/radio_button.rb', line 6 def create_view() = props[:previous_button].nil? ? nil : props[:previous_button].view RadioButtonView.new( previous_button: , on_toggled: proc{ |state:| on_toggled(state: state) } ) end |
#on_toggled(state:) ⇒ Object
27 28 29 30 31 |
# File 'lib/components/widgets/radio_button.rb', line 27 def on_toggled(state:) return if model.nil? model.set_selection(props[:id]) if state == true end |
#on_value_changed(announcement) ⇒ Object
Events
23 24 25 |
# File 'lib/components/widgets/radio_button.rb', line 23 def on_value_changed(announcement) view.set_value(announcement.new_value) end |