Class: MittensUi::Checkbox
Overview
A checkbox widget that can be toggled on and off. Wraps Gtk::CheckButton.
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Core
Instance Method Summary collapse
-
#checked? ⇒ Boolean
Returns whether the checkbox is currently checked.
-
#initialize(options = {}) ⇒ Checkbox
constructor
Creates a new Checkbox widget.
-
#toggle { ... } ⇒ void
Connects a block to the toggle event.
Methods inherited from Core
#hidden?, #hide, #keyboard_shortcut, #remove, #remove_keyboard_shortcut, #render, #shortcuts, #show
Methods included from Helpers
#icon_map, #list_system_icons, #set_margin_from_opts_for
Constructor Details
#initialize(options = {}) ⇒ Checkbox
Creates a new Checkbox widget.
26 27 28 29 30 31 32 |
# File 'lib/mittens_ui/checkbox.rb', line 26 def initialize( = {}) label = .fetch(:label, 'Checkbox') @value = nil @checkbox = Gtk::CheckButton.new @checkbox.set_label(label.to_s) super(@checkbox, ) end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
18 19 20 |
# File 'lib/mittens_ui/checkbox.rb', line 18 def value @value end |
Instance Method Details
#checked? ⇒ Boolean
Returns whether the checkbox is currently checked.
48 49 50 |
# File 'lib/mittens_ui/checkbox.rb', line 48 def checked? @checkbox.active? end |
#toggle { ... } ⇒ void
This method returns an undefined value.
Connects a block to the toggle event. Called whenever the checkbox is checked or unchecked.
39 40 41 42 43 |
# File 'lib/mittens_ui/checkbox.rb', line 39 def toggle @checkbox.signal_connect('toggled') do yield end end |