Class: Interphase::Button
- Defined in:
- lib/interphase/widgets/button.rb
Overview
A button which can perform an action upon being clicked.
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#click ⇒ Object
Clicks the button, executing any blocks added using
#on_click
. -
#initialize(label = '', **options, &block) ⇒ Button
constructor
Create a new button.
-
#label ⇒ Object
Get the button’s label text.
-
#label=(value) ⇒ Object
Set the button’s label text.
-
#on_click(&block) ⇒ Object
Register a block to execute upon clicking the button.
Methods inherited from Widget
#destroy, #method_missing, #on, #respond_to_missing?, #show, #size
Constructor Details
#initialize(label = '', **options, &block) ⇒ Button
Create a new button.
label
-
The text to display on the button.
10 11 12 |
# File 'lib/interphase/widgets/button.rb', line 10 def initialize(label = '', **, &block) super(Gtk::Button.new(label), **, &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Interphase::Widget
Instance Method Details
#click ⇒ Object
Clicks the button, executing any blocks added using #on_click
.
30 31 32 |
# File 'lib/interphase/widgets/button.rb', line 30 def click gtk_instance.clicked end |
#label ⇒ Object
Get the button’s label text.
15 16 17 |
# File 'lib/interphase/widgets/button.rb', line 15 def label gtk_instance.label end |
#label=(value) ⇒ Object
Set the button’s label text.
20 21 22 |
# File 'lib/interphase/widgets/button.rb', line 20 def label=(value) gtk_instance.label = value end |
#on_click(&block) ⇒ Object
Register a block to execute upon clicking the button.
25 26 27 |
# File 'lib/interphase/widgets/button.rb', line 25 def on_click(&block) on('clicked', &block) end |