Class: RAutomation::Adapter::WinFfi::SelectList::SelectListOption

Inherits:
Object
  • Object
show all
Defined in:
lib/rautomation/adapter/win_ffi/select_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(select_list, text, index) ⇒ SelectListOption

Returns a new instance of SelectListOption.



12
13
14
15
16
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 12

def initialize(select_list, text, index)
  @select_list = select_list
  @text = text
  @index = index
end

Instance Attribute Details

#control_hwnd

Returns the value of attribute control_hwnd.



10
11
12
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 10

def control_hwnd
  @control_hwnd
end

#index

Returns the value of attribute index.



10
11
12
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 10

def index
  @index
end

#text

Returns the value of attribute text.



10
11
12
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 10

def text
  @text
end

Instance Method Details

#select Also known as: set



24
25
26
27
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 24

def select
  @select_list.assert_enabled
  Functions.send_message(@select_list.control_hwnd, Constants::CB_SETCURSEL, @index, nil) != Constants::CB_ERR
end

#selected?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 18

def selected?
  selected_idx = Functions.send_message(@select_list.control_hwnd, Constants::CB_GETCURSEL, 0, nil)
  return false if selected_idx == Constants::CB_ERR
  @text == Functions.retrieve_combobox_item_text(@select_list.control_hwnd, selected_idx)
end