Sha256: 6f2ce1a67a48f9e9519697cd8da6edb691199e9a3781c9e707176475fe103f0a

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

module VER
  # Some convenience methods for the default {Tk::Tile::Treeview}
  class Treeview < Tk::Tile::Treeview
    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

    # 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.
    def line_up(event = nil)
      Tk.eval(LINE_UP.gsub(/%path%/, tk_pathname))
    end

    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

    # 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.
    def line_down(event = nil)
      Tk.eval(LINE_DOWN.gsub(/%path%/, tk_pathname))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ver-2010.08 lib/ver/treeview.rb
ver-2010.02 lib/ver/treeview.rb