lib/under_os/ui/button.rb in under-os-1.1.0 vs lib/under_os/ui/button.rb in under-os-1.2.0
- old
+ new
@@ -2,11 +2,13 @@
wraps UIButton, tag: 'button'
def initialize(options={})
super
- self.text = options.delete(:text) || ''
+ self.text = options.delete(:text) || ''
+ self.disable if options[:disabled]
+
@_.showsTouchWhenHighlighted = true
@_.setBackgroundImage(options.delete(:image), forState:UIControlStateNormal) if options[:image]
@_.sizeToFit
end
@@ -15,8 +17,26 @@
end
def text=(new_text, state=UIControlStateNormal)
@_.setTitle new_text, forState:state
repaint
+ end
+
+ def disabled
+ ! @_.isEnabled
+ end
+
+ alias :disabled? :disabled
+
+ def disabled=(value)
+ @_.enabled = ! value
+ end
+
+ def disable
+ self.disabled = true
+ end
+
+ def enable
+ self.disabled = false
end
end