Tk-TableMatrix
view release on metacpan or search on metacpan
TableMatrix/Spreadsheet.pm view on Meta::CPAN
Dragging these handles will resize the row or column. If multiple rows or columns
are selected, then the new row/col size will apply to all row/cols selected.
Note: With the base Tk::TableMatrix, it is possible to resize the row/cols by dragging
on any cell border. To be more spreadsheet-like, Tk::TableMatrix::Spreadsheet defaults to enable row/col
resizing only thru the title row/col dragging. To override this default behavoir, set the -resizeborder option to
'both' at startup.
=item *
A popup menu for row/col insert/delete appears when the mouse is right-clicked in the
row/col title areas.
=item *
Cells activate (i.e. the contents become edit-able) only when the cell is double-clicked
or the F2 button is pressed. The default L<Tk::TableMatrix> behavior is for the
cell to be activated when the cell is single-clicked.
=item *
The Escape key causes any changes made to a cell to be canceled and the current
selection cleared.
=item *
The return key causes the the current cell to move down.
=item *
The tab (or shift tab) key causes the current cell to be moved to the right (left).
=item *
The delete key will delete the current selection, if no cell is currently active.
=item *
The Mouse button 2 (middle button) paste from the PRIMARY. (Control-v pastes from the
clipboard).
=back
=head1 Additional Information
Widget methods, options, etc, are inherited from the L<Tk::TableMatrix> widget. See its
docs for additional information.
=cut
package Tk::TableMatrix::Spreadsheet;
use Carp;
use Tk;
use Tk::TableMatrix;
use Tk::Derived;
use base qw/ Tk::Derived Tk::TableMatrix/;
$VERSION = '1.29';
Tk::Widget->Construct("Spreadsheet");
sub ClassInit{
my ($class,$mw) = @_;
$class->SUPER::ClassInit($mw);
# Bind our motion routine to change cursors for row/column resize
$mw->bind($class,'<Motion>',['GeneralMotion',$mw]);
# Over-ride default button release binding
# so a cell won't activate by just clicking
$mw->bind($class,'<ButtonRelease-1>',['Button1Release', $mw]);
# Edit (activate) a cell if it is double-clicked
# Or F2 is pressed
$mw->bind($class,'<Double-1>',
sub
{
my $w = shift;
my $Ev = $w->XEvent;
if ($w->exists)
{
$w->CancelRepeat;
$w->activate('@' . $Ev->x.",".$Ev->y);
}
}
);
$mw->bind($class,'<F2>',
sub
{
my $w = shift;
my $Ev = $w->XEvent;
if ($w->exists)
{
$w->CancelRepeat;
my $location = '@' . $Ev->x.",".$Ev->y;
#print "location = $location\n";
if( $w->selectionIncludes($location)){
$w->activate('@' . $Ev->x.",".$Ev->y);
}
}
}
);
$mw->bind($class,'<Escape>',
sub
{
my $w = shift;
$w->reread; # undo any changes if editing a cell
my $upperLeft = $w->cget(-roworigin).",".$w->cget(-colorigin);
$w->activate($upperLeft);
( run in 0.769 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )