Class: CyberarmEngine::Element::CheckBox
- Inherits:
-
Flow
- Object
- CyberarmEngine::Element
- Container
- Flow
- CyberarmEngine::Element::CheckBox
- Defined in:
- lib/cyberarm_engine/ui/elements/check_box.rb
Constant Summary
Constants included from Theme
Instance Attribute Summary
Attributes inherited from Container
#children, #fill_color, #gui_state, #scroll_x, #scroll_y, #stroke_color
Attributes inherited from CyberarmEngine::Element
#background_canvas, #border_canvas, #enabled, #event_handler, #options, #parent, #style, #tip, #x, #y, #z
Instance Method Summary collapse
-
#initialize(text, options, block = nil) ⇒ CheckBox
constructor
A new instance of CheckBox.
- #text=(text) ⇒ Object
- #value ⇒ Object
- #value=(bool) ⇒ Object
Methods inherited from Flow
Methods inherited from Container
#add, #build, #clear, #fits_on_line?, #hit_element?, #layout, #max_width, #move_to_next_line, #position_on_current_line, #position_on_next_line, #recalculate, #render, #tallest_neighbor, #to_s, #update, #write_tree
Methods included from Common
#current_state, #darken, #draw_rect, #fill, #get_asset, #get_image, #get_sample, #get_song, #lighten, #opacity, #pop_state, #previous_state, #push_state, #show_cursor, #show_cursor=, #window
Methods inherited from CyberarmEngine::Element
#background=, #button_down, #button_up, #content_height, #content_width, #default_events, #dimensional_size, #draggable?, #draw, #enabled?, #height, #hide, #hit?, #inner_height, #inner_width, #is_root?, #noncontent_height, #noncontent_width, #outer_height, #outer_width, #recalculate, #render, #reposition, #root, #set_background, #set_border_color, #set_border_thickness, #set_margin, #set_padding, #set_static_position, #show, #stylize, #to_s, #toggle, #update, #update_background, #visible?, #width
Methods included from CyberarmEngine::Event
#event, #publish, #subscribe, #unsubscribe
Methods included from Theme
#deep_merge, #default, #theme_defaults
Constructor Details
#initialize(text, options, block = nil) ⇒ CheckBox
Returns a new instance of CheckBox.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 4 def initialize(text, , block = nil) super(, block) [:toggled] = [:checked] = ToggleButton.new() @label = Label.new(text, ) @label.subscribe(:holding_left_mouse_button) do |sender, x, y| .(sender, x, y) end @label.subscribe(:released_left_mouse_button) do |sender, x, y| .(sender, x, y) end @label.subscribe(:clicked_left_mouse_button) do |sender, x, y| .(sender, x, y) publish(:changed, .value) end @label.subscribe(:enter) do |sender| .enter(sender) end @label.subscribe(:leave) do |sender| .leave(sender) end add() add(@label) end |
Instance Method Details
#text=(text) ⇒ Object
36 37 38 39 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 36 def text=(text) @label.text = text recalculate end |
#value ⇒ Object
41 42 43 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 41 def value .value end |
#value=(bool) ⇒ Object
45 46 47 48 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 45 def value=(bool) .value = bool publish(:changed, .value) end |