my problem is that the subroutine from “-browsecmd” is called twice, when a user clicks on an entry. It activates when the left mouse button is pressed and when it is released. Is it possible to tell “-browsecmd” to only activate once?
Here is an example script that demonstrates my problem. Whenever a user clicks on an entry the print function is called twice.
#!/usr/bin/perl
use strict;
use warnings;
use English qw( -no_match_vars );
use Tk;
use Tk::Tree;
my $mw = MainWindow->new();
my $tree = $mw->Tree(
-width => '25',
-browsecmd => \sub {
my ($numbers) = @ARG;
print $numbers. "\n";
}
);
foreach (qw(one two three four five six )) {
$tree->add( $ARG, -text => $ARG ); #populates the tree
}
$tree->pack();
MainLoop();
Thanks for reading my message.
EDIT1: Forgot to post the link to the Tk::Tree Documentation
There’s way to get rid of that behavior:
Found this by browsing the doc for the parent widget:
Tk::HList(theBINDINGSsection is interesting).