Class: Scarpe::WASMEditLine
- Inherits:
-
WASMWidget
- Object
- Shoes::Linkable
- WASMWidget
- Scarpe::WASMEditLine
- Defined in:
- lib/scarpe/wasm/edit_line.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Attributes inherited from WASMWidget
#children, #parent, #shoes_linkable_id
Instance Method Summary collapse
- #element ⇒ Object
-
#initialize(properties) ⇒ WASMEditLine
constructor
A new instance of WASMEditLine.
- #properties_changed(changes) ⇒ Object
Methods inherited from WASMWidget
#bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #set_parent, #to_html
Constructor Details
#initialize(properties) ⇒ WASMEditLine
Returns a new instance of WASMEditLine.
7 8 9 10 11 12 13 14 |
# File 'lib/scarpe/wasm/edit_line.rb', line 7 def initialize(properties) super # The JS handler sends a "change" event, which we forward to the Shoes widget tree bind("change") do |new_text| send_self_event(new_text, event_name: "change") end end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/scarpe/wasm/edit_line.rb', line 5 def text @text end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/scarpe/wasm/edit_line.rb', line 5 def width @width end |
Instance Method Details
#element ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/scarpe/wasm/edit_line.rb', line 25 def element oninput = handler_js_code("change", "this.value") HTML.render do |h| h.input(id: html_id, oninput: oninput, value: @text, style: style) end end |
#properties_changed(changes) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/scarpe/wasm/edit_line.rb', line 16 def properties_changed(changes) t = changes.delete("text") if t html_element.value = t end super end |