Method: Tk::BLT::Tree::Trace#initialize

Defined in:
lib/tkextlib/blt/tree.rb

#initialize(tree, node, key, opts, cmd = nil, &b) ⇒ Trace

Returns a new instance of Trace.



533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/tkextlib/blt/tree.rb', line 533

def initialize(tree, node, key, opts, cmd=nil, &b)
  @parent = @tree = tree
  @tpath = @parent.path

  if !cmd
    if b
      cmd = Proc.new(&b)
    else
      fail ArgumentError, "lack of 'command' argument"
    end
  end

  @path = @id = tk_call(@tpath, 'trace', 'create', node, key, opts,
                        proc{|t, id, k, ops|
                          tobj = Tk::BLT::Tree.id2obj(t)
                          if tobj.kind_of?(Tk::BLT::Tree)
                            nobj = Tk::BLT::Tree::Node.id2obj(tobj, id)
                          else
                            nobj = id
                          end
                          cmd.call(tobj, nobj, k, ops)
                        })
end