Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-10-09
16:37 • Closed ticket [469272ffff]: tk fails to grab if the workspace change plus 9 ... artifact: 4e9b2d3b7d user: dkf
2001-10-08
20:33 • New ticket [469272ffff]. artifact: ae75e32a26 user: gauravdj

tk fails to grab if the workspace change

Closed / Invalid469272ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-10-08 20:33:36
On solaris 
In case tcl takes somelong time to execute something 
and you click on the menu and changes the workspace 
before that execution is completed tcl fails

the grab -global $menu 
       in tkMenuButtonDown fails

try this use a.tcl 

click on "file"
click test
click edit and then change the workspace 

***********************************************
contents of a.tcl
***********************************************
menu .m
menu .file
menu .edit

.m add cascade -menu .file -label File
.file add command -label "Test" -command longtime

.m add cascade -menu .edit -label Edit
.edit add command -label "Hello"

. configure -menu .m

proc longtime {} {
  after 5000
  puts "POSTED"
}

proc tkMenuButtonDown menu {
    global tkPriv
    global tcl_platform

    if {![winfo viewable $menu]} {
        return
    }
    $menu postcascade active
    if {[string compare $tkPriv(postedMb) ""] && \
    [winfo viewable $tkPriv(postedMb)]} {
grab -global $tkPriv(postedMb)
    } else {
while {[string equal [$menu cget -
type] "normal"] \
&& [string equal [winfo class [winfo 
parent $menu]] "Menu"] \
&& [winfo ismapped [winfo parent 
$menu]]} {
    set menu [winfo parent $menu]
}

if {[string equal $tkPriv(menuBar) {}]} {
    set tkPriv(menuBar) $menu
    set tkPriv(cursor) [$menu cget -cursor]
    $menu configure -cursor arrow
        }

# Don't update grab information if the grab 
window isn't changing.
# Otherwise, we'll get an error when we unpost 
the menus and
# restore the grab, since the old grab window 
will not be viewable
# anymore.

if {[string compare $menu [grab current 
$menu]]} {
    tkSaveGrabInfo $menu
}

# Must re-grab even if the grab window hasn't 
changed, in order
# to release the implicit grab from the button 
press.

if {[string equal $tcl_platform
(platform) "unix"]} {
    puts "MAPPED [winfo ismapped $menu]"
    puts "VIEWABLE [winfo viewable $menu]"
    puts "STATE [wm state [winfo toplevel 
$menu]]"
    grab -global $menu
}
    }
}
dkfplain2001-10-09 16:37:41
Logged In: YES 
user_id=79902

This is not a tcl bug. (And it works for me in 8.3.2 too.)
Log in (anonymous is fine) to add a comment.