class Lebowski::Foundation::Views::TextFieldView

Represents a proxy to a SproutCore text field view (SC.TextFieldView)

Constants

SELECTOR_INPUT_FIELD
SELECTOR_TEXT_AREA

Public Instance Methods

clear() click to toggle source
# File lib/lebowski/foundation/views/text_field.rb, line 28
def clear()
  type ""
end
empty?() click to toggle source

Used to check if this view is empty

# File lib/lebowski/foundation/views/text_field.rb, line 23
def empty?()
  val = self['value']
  return (val.nil? or val.empty?)
end
key_down(char) click to toggle source
# File lib/lebowski/foundation/views/text_field.rb, line 32
def key_down(char)
  cq = core_query(text_field_selector)
  input = cq[0]
  input.key_down char
  cq.done
end
key_up(char) click to toggle source
# File lib/lebowski/foundation/views/text_field.rb, line 39
def key_up(char)
  cq = core_query(text_field_selector)
  input = cq[0]
  input.key_up char
  cq.done
end
type(text) click to toggle source

Used to type text into this view. This will directly insert the text into the input field. There will be no simulated key up and key down events

# File lib/lebowski/foundation/views/text_field.rb, line 51
def type(text)
  cq = core_query(text_field_selector)
  input = cq[0]
  input.type text
  cq.done
end
type_append(text) click to toggle source
# File lib/lebowski/foundation/views/text_field.rb, line 58
def type_append(text)
  val = self['value']
  type "#{val}#{text}"
end
type_key(text) click to toggle source

Used to simulate the typing of a single key. This will cause a simulated key up and key down event

# File lib/lebowski/foundation/views/text_field.rb, line 67
def type_key(text)
  clear
  type_key_append text
end
type_key_append(text) click to toggle source
# File lib/lebowski/foundation/views/text_field.rb, line 72
def type_key_append(text)
  cq = core_query(text_field_selector)
  input = cq[0]
  input.type_key text
  cq.done
end
type_keys(text) click to toggle source

Used to simulate the typing of some given text. Each character from the given text will “typed” meaning that a simulated key up and key down event will occur for each character. This is useful when you have something that reacts to each character being entered.

# File lib/lebowski/foundation/views/text_field.rb, line 85
def type_keys(text)
  clear
  type_keys_append text
end
type_keys_append(text) click to toggle source
# File lib/lebowski/foundation/views/text_field.rb, line 90
def type_keys_append(text)
  cq = core_query(text_field_selector)
  input = cq[0]
  text.chars.each do |x|
    input.type_key x
  end
  cq.done
end

Private Instance Methods

text_field_selector() click to toggle source
# File lib/lebowski/foundation/views/text_field.rb, line 101
def text_field_selector()
  return (self['isTextArea'] == true) ? SELECTOR_TEXT_AREA : SELECTOR_INPUT_FIELD
end