Tcl-pTk

 view release on metacpan or  search on metacpan

lib/Tcl/pTk/TableMatrix/Spreadsheet.pm  view on Meta::CPAN

over a row/col border line in the rol/col title area. 

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<Tcl::pTk::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<Tcl::pTk::TableMatrix> widget. See its 
docs for additional information.

=cut




use Carp;


use Tcl::pTk (qw/ Ev /);
use Tcl::pTk::TableMatrix;
use Tcl::pTk::Derived;

use base qw/ Tcl::pTk::Derived Tcl::pTk::TableMatrix/;


Tcl::pTk::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, Ev('x'), Ev('y')]);

	# 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 ($x,$y) = @_;
		  if ($w->Exists)
		   {
		    $w->CancelRepeat;
		    $w->activate('@' . $x.",".$y);
		   }
		 }, Ev('x'), Ev('y')
                 ]
	);
	$mw->bind($class,'<F2>',
		[sub
		 {
		  my $w = shift;
                  my ($x,$y) = @_;
		  if ($w->Exists)
		   {
		    $w->CancelRepeat;
                    # Get the current selected cell, if one exists
                    my $location = eval { $w->index('anchor'); }; 
                   
		    # print "location = $location\n";
                    return unless($location);

                    $w->activate($location);
		   }
		 }, Ev('x'), Ev('y')
                 ]
	);




	$mw->bind($class,'<Escape>',
		sub
		 {
		  my $w = shift;



( run in 0.602 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )