Class: UnderOS::UI::Button

Inherits:
View
  • Object
show all
Defined in:
lib/under_os/ui/button.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Button

Returns a new instance of Button.



4
5
6
7
8
9
10
11
12
13
# File 'lib/under_os/ui/button.rb', line 4

def initialize(options={})
  super

  self.text = options.delete(:text) || ''
  self.disable if options[:disabled]

  @_.showsTouchWhenHighlighted = true
  @_.setBackgroundImage(options.delete(:image), forState:UIControlStateNormal) if options[:image]
  @_.sizeToFit
end

Instance Method Details

#disableObject



34
35
36
# File 'lib/under_os/ui/button.rb', line 34

def disable
  self.disabled = true
end

#disabledObject Also known as: disabled?



24
25
26
# File 'lib/under_os/ui/button.rb', line 24

def disabled
  ! @_.isEnabled
end

#disabled=(value) ⇒ Object



30
31
32
# File 'lib/under_os/ui/button.rb', line 30

def disabled=(value)
  @_.enabled = ! value
end

#enableObject



38
39
40
# File 'lib/under_os/ui/button.rb', line 38

def enable
  self.disabled = false
end

#textObject



15
16
17
# File 'lib/under_os/ui/button.rb', line 15

def text
  @_.currentTitle
end

#text=(new_text, state = UIControlStateNormal) ⇒ Object



19
20
21
22
# File 'lib/under_os/ui/button.rb', line 19

def text=(new_text, state=UIControlStateNormal)
  @_.setTitle new_text, forState:state
  repaint
end