Sha256: 4983c50e44ed0cf0ccef714e1a78ecdfb882c2864a655dfb51f7fa71986faf44

Contents?: true

Size: 1.76 KB

Versions: 3

Compression:

Stored size: 1.76 KB

Contents

module RAutomation
  module Adapter
    module Ffi
      class TextField
        include WaitHelper
        include Locators

        # Creates the text field object.
        # @note this method is not meant to be accessed directly, but only through {RAutomation::Window#text_field}!
        # @param [RAutomation::Window] window this text field belongs to.
        # @param [Hash] locators for searching the text field.
        # @option locators [String, Regexp] :class Internal class name of the text field
        # @option locators [String, Regexp] :value Value (text) of the text field
        # @option locators [String, Fixnum] :id Internal ID of the text field
        # @option locators [String, Fixnum] :index 0-based index to specify n-th text field if all other criteria match
        # @see RAutomation::Window#text_field
        def initialize(window, locators)
          @window = window
          extract(locators)
        end

        # @see RAutomation::TextField#set
        def set(text)
          wait_until do
            hwnd = Functions.control_hwnd(@window.hwnd, @locators)
            @window.activate
            @window.active? &&
                    Functions.set_control_focus(hwnd) &&
                    Functions.set_control_text(hwnd, text) &&
                    value == text
          end
        end

        # @see RAutomation::TextField#clear
        def clear
          set ""
        end

        # @see RAutomation::TextField#value
        def value
          Functions.control_value(Functions.control_hwnd(@window.hwnd, @locators))
        end

        # @see RAutomation::TextField#exists?
        def exists?
          !!Functions.control_hwnd(@window.hwnd, @locators)
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rautomation-0.3.0 lib/rautomation/adapter/ffi/text_field.rb
rautomation-0.2.1 lib/rautomation/adapter/ffi/text_field.rb
rautomation-0.2.0 lib/rautomation/adapter/ffi/text_field.rb