Class: Sirens::InputText

Inherits:
PrimitiveComponent show all
Defined in:
lib/components/widgets/input_text.rb

Instance Method Summary collapse

Methods inherited from PrimitiveComponent

#apply_props, #initialize, #on_component_added, #on_model_changed, #populate_popup_menu, #set_props, #subscribe_to_model_events

Methods inherited from AbstractComponent

#add_all_components, #add_component, #child_components, #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

#create_viewObject

Returns a TextView.



6
7
8
# File 'lib/components/widgets/input_text.rb', line 6

def create_view()
    InputTextView.new
end

#default_modelObject

Returns a default model if none is given during the initialization of this component.



13
14
15
# File 'lib/components/widgets/input_text.rb', line 13

def default_model()
    ValueModel.on('')
end

#on_value_changed(announcement) ⇒ Object

Events



23
24
25
# File 'lib/components/widgets/input_text.rb', line 23

def on_value_changed(announcement)
    view.set_text(announcement.new_value)
end

#sync_ui_from_modelObject



17
18
19
# File 'lib/components/widgets/input_text.rb', line 17

def sync_ui_from_model()
    view.set_text(model.value) unless view.nil?
end