Method: Tk::BLT::Treeview::Node.new

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

.new(tree, pos, parent = nil, keys = {}) ⇒ Object



1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
# File 'lib/tkextlib/blt/treeview.rb', line 1090

def self.new(tree, pos, parent=nil, keys={})
  if parent.kind_of?(Hash)
    keys = parent
    parent = nil
  end

  keys = _symbolkey2str(keys)
  tpath = tree.path

  TreeNodeID_TBL.mutex.synchronize{
    TreeNodeID_TBL[tpath] ||= {}
    if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
      keys.delete('node')
      tk_call(tree.path, 'move', id, pos, parent) if parent
      return obj
    end

    #super(tree, pos, parent, keys)
    (obj = self.allocate).instance_eval{
      initialize(tree, pos, parent, keys)
      TreeNodeID_TBL[tpath][@id] = self
    }
    obj
  }
end