Class: Interphase::Button

Inherits:
Widget
  • Object
show all
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

#gtk_instance, #name, #parent

Instance Method Summary collapse

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 = '', **options, &block)
  super(Gtk::Button.new(label), **options, &block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Interphase::Widget

Instance Method Details

#clickObject

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

#labelObject

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