ttk::treeview - Different bindings

24.12.2014 HE The intention of this side is to collect code which change the behavior of the ttk::treeview.

The width of columns can be changed with dragging the separator between two headings with the mouse. One problem could be that not only the wanted column is affected by dragging.

The below code change build-in procedures so that only the width of the wanted column is changed. Simply source them into your code.

proc ttk::treeview::resize.press {w x y} {
        variable State
        set State(pressMode) "resize"
        set State(resizeColumn) [$w identify column $x $y]
        set State(oldX) $x
}
proc ttk::treeview::resize.drag {w x} {
        variable State
        set curWidth [$w column $State(resizeColumn) -width]
        set minWidth [$w column $State(resizeColumn) -minwidth]
        set newWidth [expr {$curWidth - ($State(oldX) - $x)}]
        if {$newWidth < $minWidth} {
                set newWidth $minWidth
        }
        $w column $State(resizeColumn) -width $newWidth
        set State(oldX) $x
}

ttk::treeview::resize.press is only be enhanced by remembering %x in the array ttk::treeview::State. This means also that array has a new entry.

ttk::treeview::resize.drag is rewritten to calculate the width of the column itself instead of using '%w drag'.