Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Workaround Re: Tktable browsecommand question
John Seal wrote:
>     after 2000 set ::Done 1; tkwait variable ::Done

> I'm thinking that the way to handle that is to check at the
> very end of the browsecommand whether another cell has been activated
> and, if so, process it.

Here's an update. My demo code has a bug in the simulated lengthy
event-looping browsecommand. It turns out that browsecommands can nest,
so it has to wait for the specific cell being processed.

The updated demo shown below also shows that my proposed fix does indeed
work. If you comment out the fix, it still exhibits the behavior that I
originally questioned.

package require Tktable
set ::Format "%8s %8s %8s %8s %s"
proc log {cell {tag ""} {mark ""}} {
set act [.t tag cell active]
set sel [.t tag cell sel]
puts [format $::Format $tag $cell $act $sel $mark]
}
proc browse {cell} {
log $cell browse \\
update idletasks
# Works if you comment out everything after 2000, or change
# the table -browsecommand to {after idle browse %C}
after 2000 set ::Done($cell) 1; tkwait variable ::Done($cell)
log $cell done /
# Workaround for possibly ignoring the last click.
# Cancel and reschedule to avoid piling up checks.
set ::LastBrowsed $cell
after cancel check
after idle check
}
proc check {} {
set act [.t tag cell active]
if {$::LastBrowsed ne $act} {browse $act}
}
table .t -state disabled -selectmode extended -exportselection false \
-browsecommand {browse %C}
bind .t <1> {log [%W index @%x,%y] click}
pack .t
puts [format $::Format "" cell active select ""]
catch {console show}

The format of the output has been improved, with brackets added to make
it easy to spot browse/done pairs. When I ran this demo, then clicked on
the top left cell and the 5 below it, I got this output:

cell   active   select
click      0,0
browse      0,0      0,0      0,0 \
click      1,0      0,0      0,0
click      2,0      1,0      1,0
click      3,0      2,0      2,0
done      0,0      3,0      3,0 /
browse      3,0      3,0      3,0 \
click      4,0      3,0      3,0
browse      4,0      4,0      4,0 \
click      5,0      4,0      4,0
done      4,0      5,0      5,0 /
done      3,0      5,0      5,0 /
browse      5,0      5,0      5,0 \
done      5,0      5,0      5,0 /

Note that the browsecommand for cells 3,0 and 4,0 nested, and that the
last click on 5,0 was sucessfully picked up. If you comment out the
workaround and repeat the run, the last click is sometimes ignored.

Report this thread to moderator Post Follow-up to this message
Old Post
John Seal
11-22-07 03:15 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Tcl archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:02 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.