This page was started on Saturday, July 13, 2002.
Rohan Pall writes about his short but lively experience with tk_popup:
Why do I care about this?
My ultrat (ultra table) package makes it easy for me to quickly make auto-scrolled tables that have a cool way of hiliting the item under the mouse. I also wanted a popup when the right-button is clicked over an item, like you've prolly seen in lots of progs. The problem was that tk_popup is inconsistent on different platforms. So I worked around it. Now I'm showing you what I figured out in the hopes that it helps y'all. And this way I'll remember a year from now what I was doing ;)
Platform diffs
I've noticed some diffs with tk_popup on windows and on unix, specifically on Windows98 and on Linux. I use $::tcl_platform(platform) to test what platform I'm on, i.e. "windows" or "unix".
windows:
I'm assuming this happens because the native windows menu widget is being called, and not a Tk toplevel. All I know for sure is that I have observed this widget phenomena. Here is an
unix:
This inconsistent behavior causes problems when doing cool things with The Cool Language.
Code that shows you the prob, bob
Run this code on windows and unix. Notice how as soon as the popup is displayed on unix, the message that the script is resuming is displayed. See how on windows this only happens after the popup dissapears (is dismissed, whatever).
set noob [label .noob -text noob -bg purple -fg red] pack $noob set t [text .t -height 20 -width 70 -wrap none] pack $t -fill both -expand 1 proc ins {msg} { global t $t insert end \ "[clock format [clock seconds] -format %T] $msg\n" } set m [menu .m -tearoff 0] $m add command \ -label Party! \ -command [list ins "Noob Party!"] \ -underline 0 bind $noob <Button-3> [list showpopup %X %Y] proc showpopup {X Y} { global m t tk_popup $m $X $Y ins "script resumes now after tk_popup command..." return }