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.



487
488
489
# File 'lib/AutoItX3/control.rb', line 487

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)


531
532
533
# File 'lib/AutoItX3/control.rb', line 531

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

#collapse(item) ⇒ Object

Collapses item to hide its children.



492
493
494
# File 'lib/AutoItX3/control.rb', line 492

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

#exists?(item) ⇒ Boolean

Return wheather or not item exists.

Returns:

  • (Boolean)


497
498
499
# File 'lib/AutoItX3/control.rb', line 497

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

#expand(item) ⇒ Object

Expands item to show its children.



502
503
504
# File 'lib/AutoItX3/control.rb', line 502

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

#num_subitems(item) ⇒ Object

Returns the number of children of item.



507
508
509
# File 'lib/AutoItX3/control.rb', line 507

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

#select(item) ⇒ Object

Selects item.



536
537
538
# File 'lib/AutoItX3/control.rb', line 536

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.



513
514
515
516
517
# File 'lib/AutoItX3/control.rb', line 513

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:



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

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.



524
525
526
# File 'lib/AutoItX3/control.rb', line 524

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).



541
542
543
# File 'lib/AutoItX3/control.rb', line 541

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