in reply to Re^2:How to bind single click to get an path of an entry in Tk::HList
in thread How to bind single click to get an path of an entry in Tk::HList
This change to the code creating the Tk::HList widget will cause a changing, pipe ('|') separated, list of paths to appear in the Tk::Label as you move the mouse and highlight different parts of the tree.
my $hlist; $hlist = $app_F->HList( -itemtype => 'text', -selectmode => 'extended', -browsecmd => sub { $label_text = join '|' => $hlist->selectionGet + }, );
The (possibly) odd-looking "my $hlist; $hlist = ..." is intended: $hlist is used in the -browsecmd callback, so it needs to be declared before the widget is created and assigned to that variable. There's no syntactical reason for putting the separate declaration and assignment on the same line: use whatever style suits you.
As before, process the array returned by $hlist->selectionGet however you want. Also, see the Tk::HList documentation for how this behaves differently in scalar context.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to bind single click to get an path of an entry in Tk::HList
by rjohn1 (Sexton) on Apr 18, 2014 at 14:39 UTC | |
by kcott (Archbishop) on Apr 18, 2014 at 21:15 UTC |