Skip Menu |

This queue is for tickets about the Tk-TableMatrix CPAN distribution.

Report information
The Basics
Id: 70324
Status: resolved
Priority: 0/
Queue: Tk-TableMatrix

People
Owner: Nobody in particular
Requestors: henry.merryweather [...] btinternet.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: suspected discrepancy with active cell
Date: Wed, 17 Aug 2011 21:42:31 +0100
To: bug-Tk-TableMatrix [...] rt.cpan.org
From: Henry Merryweather <henry.merryweather [...] btinternet.com>
I have something that I do understand about what is given for the selected cell in a table matrix. The Perl below creates a table matrix and the sub brscmd is used whenever a cell is slected using either the left hand mouse key or the up/down and left/right keys on the key board. The selected cell is obtained in two ways. These are 1. from the 'standard' argument to the browse sub; 2. using $t->curselection() where $t is the table matrix. Both values are printed out. When I use the left hand mouse key both values are the same. When I use the keyboard keys, the value from curselection always seems to be that for the previous selection of a cell. I suspect that something is not as it should be. use Tk; use Tk::TableMatrix; my $mw = MainWindow->new; my $arrayVar = {}; print "Filling Array...\n"; my ($rows,$cols) = (10, 10); foreach my $row (0..($rows-1)){ foreach my $col (0..($cols-1)){ $arrayVar->{"$row,$col"} = 2*$row + 3*$col; } } print "Creating Table...\n"; my $t = $mw->Scrolled('TableMatrix', -rows => $rows, -cols => $cols, -width => 10, -height => 10, -titlerows => 1, -titlecols => 1, -variable => $arrayVar, -coltagcommand => \&colSub, -browsecommand => \&brscmd, -colstretchmode => 'last', -rowstretchmode => 'last', -selectmode => 'extended', -selecttitles => 0, -drawmode => 'slow', -scrollbars=>'se' ); $t->pack(-expand => 1, -fill => 'both'); Tk::MainLoop; sub brscmd { my ($previous_index, $actual_index) = @_; my ($row, $col) = split ',', $actual_index; my ($sel, $js); my $sel = $t->curselection(); foreach $js (@$sel) { print "\n[brscmd] actual index <$actual_index> from curselection <+$js>\n"; } } Best regards Henry Merryweather
Subject: Fwd: suspected discrepancy with active cell
Date: Wed, 17 Aug 2011 21:49:50 +0100
To: bug-Tk-TableMatrix [...] rt.cpan.org
From: Henry Merryweather <henry.merryweather [...] btinternet.com>
/I am sorry but I had not fully read what is required with a bug. Therefore I am sending this again with as much as I can of that infomration. Please let me know if you need more. The results of using perl -v were / This is perl 5, version 12, subversion 2 (v5.12.2) built for MSWin32-x86-multi-thread (with 2 registered patches, see perl -V for more detail) /The results of using perl -V were/ Summary of my perl5 (revision 5 version 12 subversion 2) configuration: Platform: osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=y, bincompat5005=undef Compiler: cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DE S_FCRYPT -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DPERL_DEBUGGING_MSTATS -DPERL_IMPL ICIT_CONTEXT -DUSE_PERLIO', optimize='-MD -Zi -DNDEBUG -O1', cppflags='-DWIN32' ccversion='16.00.30319.01', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -libpath:"C:\Radview\perl5\lib\C ORE" -machine:x86 "/manifestdependency:type='Win32' name='Microsoft.Windows.Common-Controls' versio n='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'"' libpth=\lib libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib sh ell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib od bc32.lib odbccp32.lib comctl32.lib msvcrt.lib perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.li b shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.li b odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl512.lib gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -libpath:"C:\Radview\ perl5\lib\CORE" -machine:x86 "/manifestdependency:type='Win32' name='Microsoft.Windows.Common-Contr ols' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'"' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY MYMALLOC PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF Locally applied patches: Add Visual C++ 2010 support Disable registry-lookup of missing PERL* environment variables Built under MSWin32 Compiled at Nov 29 2010 10:44:05 @INC: H:/perl5/site/lib H:/perl5/lib . /Original e-mail/ I have something that I do understand about what is given for the selected cell in a table matrix. The Perl below creates a table matrix and the sub brscmd is used whenever a cell is slected using either the left hand mouse key or the up/down and left/right keys on the key board. The selected cell is obtained in two ways. These are 1. from the 'standard' argument to the browse sub; 2. using $t->curselection() where $t is the table matrix. Both values are printed out. When I use the left hand mouse key both values are the same. When I use the keyboard keys, the value from curselection always seems to be that for the previous selection of a cell. I suspect that something is not as it should be. use Tk; use Tk::TableMatrix; my $mw = MainWindow->new; my $arrayVar = {}; print "Filling Array...\n"; my ($rows,$cols) = (10, 10); foreach my $row (0..($rows-1)){ foreach my $col (0..($cols-1)){ $arrayVar->{"$row,$col"} = 2*$row + 3*$col; } } print "Creating Table...\n"; my $t = $mw->Scrolled('TableMatrix', -rows => $rows, -cols => $cols, -width => 10, -height => 10, -titlerows => 1, -titlecols => 1, -variable => $arrayVar, -coltagcommand => \&colSub, -browsecommand => \&brscmd, -colstretchmode => 'last', -rowstretchmode => 'last', -selectmode => 'extended', -selecttitles => 0, -drawmode => 'slow', -scrollbars=>'se' ); $t->pack(-expand => 1, -fill => 'both'); Tk::MainLoop; sub brscmd { my ($previous_index, $actual_index) = @_; my ($row, $col) = split ',', $actual_index; my ($sel, $js); my $sel = $t->curselection(); foreach $js (@$sel) { print "\n[brscmd] actual index <$actual_index> from curselection <+$js>\n"; } } Best regards Henry Merryweather
The behavior you are seeing is an artifact of the additional bindings added by the Tk::TableMatrix::Spreadhsheet package on top of the base Tk::TableMatrix package. You can get consistent behavior between the mouse-click and the keyboard cell selections by using a "afterIdle" call in your browsecmd as shown below. The callback supplied to the "afterIdle" call will get executed after all the selection code has been called, which should ensure the selection has been updated. Modified brscmd with afterIdle call: sub brscmd { my ( $previous_index, $actual_index ) = @_; my ( $row, $col ) = split ',', $actual_index; my ( $sel, $js ); $t->afterIdle( sub{ my $sel = $t->curselection(); foreach $js (@$sel) { print "[brscmd] actual index <$actual_index> from curselection <+$js>\n"; } } ); }
Subject: Re: [rt.cpan.org #70324] suspected discrepancy with active cell
Date: Sat, 20 Aug 2011 17:29:19 +0100
To: bug-Tk-TableMatrix [...] rt.cpan.org
From: Henry Merryweather <henry.merryweather [...] btinternet.com>
Thanks for that. I will try it and let you know what I find. Best regards Henry Merryweather On 20/08/2011 14:35, CERNEY via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=70324> > > The behavior you are seeing is an artifact of the additional bindings > added by the Tk::TableMatrix::Spreadhsheet package on top of the base > Tk::TableMatrix package. > > You can get consistent behavior between the mouse-click and the keyboard > cell selections by using a "afterIdle" call in your browsecmd as shown > below. The callback supplied to the "afterIdle" call will get executed > after all the selection code has been called, which should ensure the > selection has been updated. > > Modified brscmd with afterIdle call: > > sub brscmd { > > my ( $previous_index, $actual_index ) = @_; > > my ( $row, $col ) = split ',', $actual_index; > my ( $sel, $js ); > $t->afterIdle( sub{ > my $sel = $t->curselection(); > foreach $js (@$sel) { > print "[brscmd] actual index<$actual_index> > from curselection<+$js>\n"; > } > } > ); > } > >
Subject: Re: [rt.cpan.org #70324] suspected discrepancy with active cell
Date: Sun, 21 Aug 2011 09:21:17 +0100
To: bug-Tk-TableMatrix [...] rt.cpan.org
From: Henry Merryweather <henry.merryweather [...] btinternet.com>
I have now tested that and reverting is fine. It also sorted out something else. In trying to find a work around to the original problem I added binds so that I could tell when either a key or button had been used. I hoped that I would be able to tell from that what to do about the selected cell. Unfortunately the 'problem' meant that the bind for the key was actioned after the brscmd was complete. Your fix means that the key bind happens in the afterIdle sub so this is now OK as well. Attached s the Perl code where this is done. One question. Are you content that I post this on Perl Monks pages in case others have similar problems. I would like to say that I have found the tablematrix features excellent for an application I have just implemented. Best regards Henry Merryweather On 20/08/2011 14:35, CERNEY via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=70324> > > The behavior you are seeing is an artifact of the additional bindings > added by the Tk::TableMatrix::Spreadhsheet package on top of the base > Tk::TableMatrix package. > > You can get consistent behavior between the mouse-click and the keyboard > cell selections by using a "afterIdle" call in your browsecmd as shown > below. The callback supplied to the "afterIdle" call will get executed > after all the selection code has been called, which should ensure the > selection has been updated. > > Modified brscmd with afterIdle call: > > sub brscmd { > > my ( $previous_index, $actual_index ) = @_; > > my ( $row, $col ) = split ',', $actual_index; > my ( $sel, $js ); > $t->afterIdle( sub{ > my $sel = $t->curselection(); > foreach $js (@$sel) { > print "[brscmd] actual index<$actual_index> > from curselection<+$js>\n"; > } > } > ); > } > >

Message body is not shown because sender requested not to inline it.

Posting on perlmonks (or whereever) is fine. -John
Subject: Re: [rt.cpan.org #70324] suspected discrepancy with active cell
Date: Mon, 22 Aug 2011 15:26:30 +0100
To: bug-Tk-TableMatrix [...] rt.cpan.org
From: Henry Merryweather <henry.merryweather [...] btinternet.com>
Ok thanks. Best regards Henry Merryweather On 22/08/2011 13:16, CERNEY via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=70324> > > Posting on perlmonks (or whereever) is fine. > > -John > >