#!/usr/bin/perl
use strict;
use Tk;
use Tk::TableMatrix;
my $mw = MainWindow->new();
my $tm = $mw->TableMatrix(
-state => 'disabled',
-browsecommand => \&brscmd,
)->pack();
MainLoop;
sub brscmd {
my ($previous_index, $actual_index) = @_;
my ($row, $col) = split ',', $actual_index;
print "r$row c$col\n";
}
| [reply] [d/l] |
| [reply] |
I thought of using "-browsecmd". I had already bound a callback to <Double-Button-1>, i.e. if the user double-clicks on a row, go do something. I just checked, and Perl/Tk does chain the callbacks in the right order, i.e. the browsecommand callback gets called before the double click callback, so I can cache the row, and retrieve it in the second callback to use it. I was just wondering if there is a way to directly access the active row(cell), without relying on the use of the browse command? That way, I would just retrieve it in my double-click callback, and be on my way. This will certainly work (Thanks), it just would be nice to be able to retrieve the selected row/cell whenever you wanted it, without having to update your stored value whenever the user clicks in the TableMatrix. | [reply] |
Here's a better example. There is also another technique, where you can get the "closet cell" to the x,y value of the mouse position, then you can do a "hover over" selection bound to mouse motion.
| [reply] [d/l] |
| [reply] |