On 2018-06-29 19:39:37, TURNERJW wrote:
Show quoted text> 1) Please add a function (or document some other way) to fetch the
> directory (string) that is currently highlighted in Tk::DirTree.
The highlighted entry is called "anchor" in Tix.
Tk::DirTree is-a Tk::Tree is-a Tk::HList.
Tk::HList documents a method $w->info("anchor") which returns the entry name, in this case the file path.
Show quoted text>
> 2) Please add some useful (default) keyboard bindings, for example:
>
> [Return] - execute -browsecmd callback on the highlighted directory
> just as if user had clicked on it with the mouse.
Currently <Return> calls the -command callback (see KeyboardActivate in HList.pm), which is the same as if doing a double click. I think it is reasonable to have double click and <Return> behave the same.
Show quoted text> [Space] - expand or roll up the subdirectories for the highlighted
> directory just as if the user clicked the little [+]/[-] icon next to
> it.
This sounds reasonable. There's an -indicatorcmd callback which is called when the user clicks on +/- or hits <space>. Tk::Tree has the predefined method IndicatorCmd which does opening/closing of subtrees. But for some reason it does not work for keyboard events. Maybe $event has to be provided here?
Show quoted text> Since there is currently no keyboard binding for changing the
> directory with this widget, I was looking for a way to bind the
> [Return] key myself and call a function that fetches the highlighted
> directory and change to it myself, but I can't find a way to get it?!
Binding can be somewhat tricky with Tk. I vaguely remember that class bindings have higher precedence than individual widget bindings in Perl/Tk (unlike Tcl/Tk). So what can you try is one of the following:
* Create a subclass, and do the bindings on this subclass.
* Use bindtags to reorder the precedence of bindings.
For debugging Tk widgets you can also try my Tk::WidgetDump module. This may help on giving information what bindings are active, and other information.
Regards,
Slaven