class MIMInputToolbar

Attributes

fields[RW]

Public Instance Methods

done_title=(title) click to toggle source
# File lib/project/MIMInputToolbar.rb, line 28
def done_title=(title)
  self.items[3].title = title
end
finish_editing(sender) click to toggle source
# File lib/project/MIMInputToolbar.rb, line 46
def finish_editing(sender)
  selected_field.resignFirstResponder
end
init() click to toggle source
Calls superclass method
# File lib/project/MIMInputToolbar.rb, line 4
def init
  super
  @fields ||= []

  self.items = [
    UIBarButtonItem.alloc.initWithTitle('Previous', style: UIBarButtonItemStylePlain, target: self, action: 'previous_field:'),
    UIBarButtonItem.alloc.initWithTitle('Next', style: UIBarButtonItemStylePlain, target: self, action: 'next_field:'),
    UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemFlexibleSpace, target: nil, action: nil),
    UIBarButtonItem.alloc.initWithTitle('Done', style: UIBarButtonItemStyleDone, target: self, action: 'finish_editing:')
  ]

  self.sizeToFit

  self
end
next_field(sender) click to toggle source
# File lib/project/MIMInputToolbar.rb, line 39
def next_field(sender)
  index = fields.index(selected_field)
  if index < fields.length - 1
    fields[index + 1].becomeFirstResponder
  end
end
next_title=(title) click to toggle source
# File lib/project/MIMInputToolbar.rb, line 24
def next_title=(title)
  self.items[1].title = title
end
previous_field(sender) click to toggle source
# File lib/project/MIMInputToolbar.rb, line 32
def previous_field(sender)
  index = fields.index(selected_field)
  if index >= 1
    fields[index - 1].becomeFirstResponder
  end
end
previous_title=(title) click to toggle source
# File lib/project/MIMInputToolbar.rb, line 20
def previous_title=(title)
  self.items[0].title = title
end
selected_field() click to toggle source
# File lib/project/MIMInputToolbar.rb, line 50
def selected_field
  fields.select { |f| f.isFirstResponder }.first
end