Class: AutoItX3::TreeView

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

Overview

A TreeView is a control that shows a kind of expandable list, like the one displayed ont the left side in .chm files.

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

#check(item) ⇒ Object

Checks item if it supports that operation.



485
486
487
# File 'lib/AutoItX3/control.rb', line 485

def check(item)
  send_command_to_tree_view("Check", item)
end

#checked?(item) ⇒ Boolean

Returns wheather or not item is checked. Raises an Au3Error if item is not a checkbox.

Returns:

  • (Boolean)


529
530
531
# File 'lib/AutoItX3/control.rb', line 529

def checked?(item)
  send_command_to_tree_view("IsChecked", item).to_i == 1
end

#collapse(item) ⇒ Object

Collapses item to hide its children.



490
491
492
# File 'lib/AutoItX3/control.rb', line 490

def collapse(item)
  send_command_to_tree_view("Collapse", item)
end

#exists?(item) ⇒ Boolean

Return wheather or not item exists.

Returns:

  • (Boolean)


495
496
497
# File 'lib/AutoItX3/control.rb', line 495

def exists?(item)
  send_command_to_tree_view("Exists", item).to_i == 1
end

#expand(item) ⇒ Object

Expands item to show its children.



500
501
502
# File 'lib/AutoItX3/control.rb', line 500

def expand(item)
  send_command_to_tree_view("Expand", item)
end

#num_subitems(item) ⇒ Object

Returns the number of children of item.



505
506
507
# File 'lib/AutoItX3/control.rb', line 505

def num_subitems(item)
  send_command_to_tree_view("GetItemCount", item).to_i
end

#select(item) ⇒ Object

Selects item.



534
535
536
# File 'lib/AutoItX3/control.rb', line 534

def select(item)
  send_command_to_tree_view("Select", item)
end

#selected(use_index = false) ⇒ Object

Returns the text reference or the index reference (if use_index is true) of the selected item.



511
512
513
514
515
# File 'lib/AutoItX3/control.rb', line 511

def selected(use_index = false)
  result = send_command_to_tree_view("GetSelected", use_index ? 1 : 0)
  return result.to_i if use_index
  result
end

#send_command_to_tree_view(command, arg1 = "", arg2 = "") ⇒ Object

Sends cmd to self. This method is only used internally.

Raises:



475
476
477
478
479
480
481
482
# File 'lib/AutoItX3/control.rb', line 475

def send_command_to_tree_view(command, arg1 = "", arg2 = "")
  Control.functions[__method__] ||= AU3_Function.new("ControlTreeView", 'SSSSSSPI')
  buffer = " " * BUFFER_SIZE
  buffer.wide!
  Control.functions[__method__].call(@title.wide, @text.wide, @c_id.wide, command.wide, arg1.wide, arg2.wide, buffer, BUFFER_SIZE - 1)
  raise(Au3Error, "Unknown error occured when sending '#{command}' to '#{@c_id}' in '#{@title}'! Maybe an invalid window?") if AutoItX3.last_error == 1
  buffer.normal.strip
end

#text_at(item) ⇒ Object Also known as: []

call-seq:

text_at( item ) ==> aString
[ item ] ==> aString

Returns the text of item.



522
523
524
# File 'lib/AutoItX3/control.rb', line 522

def text_at(item)
  send_command_to_tree_view("GetText", item)
end

#uncheck(item) ⇒ Object

Unchecks item if it suports that operation (i.e. it’s a checkbox).



539
540
541
# File 'lib/AutoItX3/control.rb', line 539

def uncheck(item)
  send_command_to_tree_view("Uncheck", item)
end