class UnderOs::UI::Input
Constants
- KEYBOARDS
Public Class Methods
new(options={})
click to toggle source
Calls superclass method
UnderOs::UI::View::new
# File lib/under_os/ui/input.rb, line 4 def initialize(options={}) super self.type = options[:type] if options[:type] self.name = options[:name] if options[:name] self.value = options[:value] if options[:value] self.placeholder = options[:placeholder] if options[:placeholder] self.keyboard = options[:keyboard] if options[:keyboard] self.disabled = true if options[:disabled] @_.delegate = self if @_.respond_to?(:delegate=) if @_.class == UITextField @_.addTarget self, action: :handle_focus, forControlEvents:UIControlEventEditingDidBegin @_.addTarget self, action: :handle_change, forControlEvents:UIControlEventEditingChanged @_.addTarget self, action: :handle_blur, forControlEvents:UIControlEventEditingDidEnd end end
Public Instance Methods
blur()
click to toggle source
# File lib/under_os/ui/input.rb, line 117 def blur @_.resignFirstResponder end
disable()
click to toggle source
# File lib/under_os/ui/input.rb, line 105 def disable self.disabled = true end
disabled()
click to toggle source
# File lib/under_os/ui/input.rb, line 95 def disabled ! @_.isEnabled end
Also aliased as: disabled?
disabled=(value)
click to toggle source
# File lib/under_os/ui/input.rb, line 101 def disabled=(value) @_.enabled = ! value end
enable()
click to toggle source
# File lib/under_os/ui/input.rb, line 109 def enable self.disabled = false end
focus()
click to toggle source
# File lib/under_os/ui/input.rb, line 113 def focus @_.becomeFirstResponder end
hide_keyboard()
click to toggle source
# File lib/under_os/ui/input.rb, line 75 def hide_keyboard puts "DEPRECATED: please use the `#blur` method instead of `#hide_keyboard`" blur end
keyboard()
click to toggle source
# File lib/under_os/ui/input.rb, line 62 def keyboard KEYBOARDS.index(@_.keyboardType) end
keyboard=(keyboard)
click to toggle source
# File lib/under_os/ui/input.rb, line 66 def keyboard=(keyboard) keyboard = keyboard.to_sym if keyboard.is_a?(String) keyboard = KEYBOARDS[keyboard] || keyboard raise "Unknown keyboard type: #{keyboard}" if keyboard.is_a?(Symbol) @_.keyboardType = keyboard end
name()
click to toggle source
# File lib/under_os/ui/input.rb, line 23 def name @name end
name=(text)
click to toggle source
# File lib/under_os/ui/input.rb, line 27 def name=(text) @name = text end
placeholder()
click to toggle source
# File lib/under_os/ui/input.rb, line 39 def placeholder @_.placeholder end
placeholder=(value)
click to toggle source
# File lib/under_os/ui/input.rb, line 43 def placeholder=(value) @_.placeholder = value end
textFieldShouldReturn(textField)
click to toggle source
delegate
# File lib/under_os/ui/input.rb, line 123 def textFieldShouldReturn(textField) blur end
type()
click to toggle source
# File lib/under_os/ui/input.rb, line 47 def type if @_.respond_to?(:secureTextEntry) && @_.secureTextEntry :password else keyboard == :default ? :text : keyboard end end
type=(type)
click to toggle source
# File lib/under_os/ui/input.rb, line 55 def type=(type) case type.to_sym when :password then @_.secureTextEntry = true else self.keyboard = type end end
value()
click to toggle source
# File lib/under_os/ui/input.rb, line 31 def value @_.text end
value=(value)
click to toggle source
# File lib/under_os/ui/input.rb, line 35 def value=(value) @_.text = value end
Protected Instance Methods
handle_blur()
click to toggle source
# File lib/under_os/ui/input.rb, line 137 def handle_blur emit('blur') end
handle_change()
click to toggle source
# File lib/under_os/ui/input.rb, line 133 def handle_change emit('change') end
handle_focus()
click to toggle source
# File lib/under_os/ui/input.rb, line 129 def handle_focus emit('focus') end