Module: Tuile::Component::HasContent
Overview
A mixin interface for a component with one child tops. The host must
provide a protected layout(content) method which repositions the
content component; the mixin manages @content itself.
Instance Attribute Summary collapse
-
#content ⇒ Component?
@return — the current content component.
Instance Method Summary collapse
- #children ⇒ Array<Component>
-
#handle_mouse(event) ⇒ void
@param
event. - #on_focus ⇒ void
-
#rect=(rect) ⇒ void
@param
rect.
Instance Attribute Details
#content ⇒ Component?
@return — the current content component.
10 11 12 |
# File 'lib/tuile/component/has_content.rb', line 10 def content @content end |
Instance Method Details
#children ⇒ Array<Component>
19 |
# File 'lib/tuile/component/has_content.rb', line 19 def children = content.nil? ? [] : [content] |
#handle_mouse(event) ⇒ void
This method returns an undefined value.
@param event
14 15 16 |
# File 'lib/tuile/component/has_content.rb', line 14 def handle_mouse(event) content.handle_mouse(event) if !content.nil? && content.rect.contains?(event.point) end |
#on_focus ⇒ void
This method returns an undefined value.
55 56 57 58 59 60 |
# File 'lib/tuile/component/has_content.rb', line 55 def on_focus super # Let the content component receive focus, so that it can immediately # start responding to key presses. screen.focused = content if !content.nil? && content.focusable? end |
#rect=(rect) ⇒ void
This method returns an undefined value.
@param rect
49 50 51 52 |
# File 'lib/tuile/component/has_content.rb', line 49 def rect=(rect) super layout(content) unless content.nil? end |