Class: AutoItX3::ListBox

Inherits:
Control show all
Defined in:
lib/AutoItX3/control.rb

Overview

List boxes are controls in which you can select one or multiple items by clicking on it. ListBox is also the superclass of ComboBox.

Direct Known Subclasses

ComboBox

Instance Method Summary collapse

Methods inherited from Control

#click, #disable, #enable, #enabled?, #focus, from_control, functions, functions=, #handle, #hide, #initialize, #move, #rect, #send_command_to_control, #send_keys, #show, #text, #text=, #visible?

Constructor Details

This class inherits a constructor from AutoItX3::Control

Instance Method Details

#<<(string) ⇒ Object

:nodoc:



371
372
373
374
# File 'lib/AutoItX3/control.rb', line 371

def <<(string) # :nodoc:
  add_item(string)
  self
end

#add_item(string) ⇒ Object

call-seq:

AutoItX3::ListBox#add( item ) ==> item
AutoItX3::ListBox#<< item ==> self

Adds an entry to an existing combo or list box. If you use the << form, you can do a chain call like:

ctrl << "a" << "b" << "c"

Parameters

string

The string to append.

Return value

The appended string or self, in the case of the operator form.

Raises

Au3Error

Control or window not found.

Example

list.add_item("my_item")
list << "my_item" << "my_second_item"


366
367
368
369
# File 'lib/AutoItX3/control.rb', line 366

def add_item(string)
  send_command_to_control("AddString", string)
  string
end

#current_selectionObject

Returns the currently selected string.

Return value

The currently selected string.

Raises

Au3Error

Control or window not found.

Example

p ctrl.current_selection #=> "my_string"


437
438
439
# File 'lib/AutoItX3/control.rb', line 437

def current_selection
  send_command_to_control("GetCurrentSelection")
end

#current_selection=(num) ⇒ Object

Sets the current selection of a combo box to item num.

Parameters

num

The index of the item to set the selection to.

Return value

num.

Raises

Au3Error

Index is out of range or the control or the window wasn’t fond.

Example

ctrl.current_selection = 3


411
412
413
414
# File 'lib/AutoItX3/control.rb', line 411

def current_selection=(num)
  send_command_to_control("SetCurrentSelection", num.to_i)
  num
end

#delete(item_number) ⇒ Object

Deletes an item.

Parameters

item_number

The 0-based index of the item to delete.

Return value

Unknown.

Raises

Au3Error

Control or window not found.

Example

list.delete(0)


385
386
387
# File 'lib/AutoItX3/control.rb', line 385

def delete(item_number)
  send_command_to_control("DelString", item.to_s).to_i
end

#find(item) ⇒ Object

Finds the item number (= 0-based index) of item in self.

Parameters

item

The item to look for.

Return value

Unknown.

Raises

Au3Error

Control or window not found.

Example

p ctrl.find("my_item") #=> 3


398
399
400
# File 'lib/AutoItX3/control.rb', line 398

def find(item)
  send_command_to_control("FindString", item).to_i
end

#select_string(str) ⇒ Object

Sets self‘s selection to the first occurence of str.

Parameters

str

The string to select.

Return value

str.

Raises

Au3Error

Couldn’t find the string, the control or the window.

Example

ctrl.select_string("my_string")


425
426
427
428
# File 'lib/AutoItX3/control.rb', line 425

def select_string(str)
  send_command_to_control("SelectString", str)
  string
end