Class: VER::Treeview

Inherits:
Tk::Tile::Treeview
  • Object
show all
Defined in:
lib/ver/treeview.rb

Overview

Some convenience methods for the default Tk::Tile::Treeview

Constant Summary collapse

LINE_UP =
<<-'TCL'.strip
set children [%path% children {}]
set children_length [llength $children]

if { $children_length > 1 } {
set item [%path% prev [%path% focus]]

if { $item == {} } { set item [lindex $children [expr $children_length - 1]] }

%path% focus $item
%path% see $item
%path% selection set $item
}
TCL
LINE_DOWN =
<<-'TCL'.strip
set children [%path% children {}]
set children_length [llength $children]

if { $children_length > 1 } {
set item [%path% next [%path% focus]]

if { $item == {} } { set item [lindex $children 0] }

%path% focus $item
%path% see $item
%path% selection set $item
}
TCL

Instance Method Summary collapse

Instance Method Details

#line_down(event = nil) ⇒ Object

Go one line in the tree down, wraps around to the top if the last item has focus.

Some lists may be huge, so we handle this in tcl to avoid lots of useless traffic between tcl and ruby. My apologies.



50
51
52
# File 'lib/ver/treeview.rb', line 50

def line_down(event = nil)
  Tk.eval(LINE_DOWN.gsub(/%path%/, tk_pathname))
end

#line_up(event = nil) ⇒ Object

Go one item in the tree up, wraps around to the bottom if the first item has focus.

Some lists may be huge, so we handle this in tcl to avoid lots of useless traffic between tcl and ruby. My apologies.



25
26
27
# File 'lib/ver/treeview.rb', line 25

def line_up(event = nil)
  Tk.eval(LINE_UP.gsub(/%path%/, tk_pathname))
end