Class: Cura::Component::Button
- Defined in:
- lib/cura/component/button.rb
Overview
A button component.
Instance Attribute Summary
Attributes included from Attributes::HasAncestry
Attributes included from Attributes::HasOffsets
Attributes included from Attributes::HasEvents
Instance Method Summary collapse
- #background ⇒ Object
-
#click ⇒ Button
Click this button.
-
#focused_background ⇒ Color
Get the focused background color of this object.
-
#focused_background=(value) ⇒ Color
Set the focused background color of this object.
-
#initialize(attributes = {}) ⇒ Button
constructor
A new instance of Button.
Methods inherited from Label
#bold=, #bold?, #draw, #height, #horizontal_alignment, #horizontal_alignment=, #lines, #text, #text=, #text_height, #text_width, #underline?, #underlined=, #vertical_alignment, #vertical_alignment=, #width
Methods included from Attributes::HasAttributes
Methods inherited from Base
#application, #contains_coordinates?, #cursor, #draw, #focus, #focused?, #foreground, #inspect, #pencil, #update
Methods included from Attributes::HasRelativeCoordinates
Methods included from Attributes::HasCoordinates
Methods included from Attributes::HasAncestry
Methods included from Attributes::HasOffsets
#border, #border=, #margin, #margin=, #padding, #padding=
Methods included from Attributes::HasColors
#background=, #foreground, #foreground=
Methods included from Attributes::HasFocusability
Methods included from Attributes::HasEvents
Methods included from Attributes::HasDimensions
#height, #height=, #resize, #width, #width=
Constructor Details
#initialize(attributes = {}) ⇒ Button
Returns a new instance of Button.
32 33 34 35 36 37 38 39 |
# File 'lib/cura/component/button.rb', line 32 def initialize(attributes={}) @focusable = true @foreground = Cura::Color.black @background = Cura::Color.white @focused_background = Color.new(78, 78, 78) super end |
Instance Method Details
#background ⇒ Object
41 42 43 |
# File 'lib/cura/component/button.rb', line 41 def background focused? ? @focused_background : get_or_inherit_color(:background, Color.black) end |
#click ⇒ Button
Click this button.
48 49 50 51 52 |
# File 'lib/cura/component/button.rb', line 48 def click application.dispatch_event(:click, target: self) self end |
#focused_background ⇒ Color
Get the focused background color of this object.
|
# File 'lib/cura/component/button.rb', line 19
|
#focused_background=(value) ⇒ Color
Set the focused background color of this object.
30 |
# File 'lib/cura/component/button.rb', line 30 attribute(:focused_background) { |value| validate_color_attribute(value) } |