Tk Source Code

Check-in [ef1b7ba6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed [fa32290898] - Can't dismiss ttk::menubutton menu until mouse has hovered over it
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ef1b7ba67b415fda4c1762845d598d6e31286fe7
User & Date: fvogel 2016-08-29 15:45:52
Context
2016-08-29
17:44
Constrained test menu-38.1 to Unix or Mac platforms since this test hangs on Windows and the corresponding bug was reported for Linux and Mac only check-in: 3d76abf4 user: fvogel tags: trunk
15:45
Fixed [fa32290898] - Can't dismiss ttk::menubutton menu until mouse has hovered over it check-in: ef1b7ba6 user: fvogel tags: trunk
15:45
Fixed [fa32290898] - Can't dismiss ttk::menubutton menu until mouse has hovered over it check-in: d4e1f680 user: fvogel tags: core-8-6-branch
15:38
Merged implementation of TIP #449 - [text] undo/redo to Return Range of Characters - following acceptation by vote of the TCT check-in: 177f5ee6 user: fvogel tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to library/menu.tcl.

602
603
604
605
606
607
608




609
610
611
612
613
614
615
# menu -		The menu window.

proc ::tk::MenuButtonDown menu {
    variable ::tk::Priv

    if {![winfo viewable $menu]} {
        return




    }
    $menu postcascade active
    if {$Priv(postedMb) ne "" && [winfo viewable $Priv(postedMb)]} {
	grab -global $Priv(postedMb)
    } else {
	while {[$menu cget -type] eq "normal" \
		&& [winfo class [winfo parent $menu]] eq "Menu" \







>
>
>
>







602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# menu -		The menu window.

proc ::tk::MenuButtonDown menu {
    variable ::tk::Priv

    if {![winfo viewable $menu]} {
        return
    }
    if {[$menu index active] eq "none"} {
        set Priv(window) {}
        return
    }
    $menu postcascade active
    if {$Priv(postedMb) ne "" && [winfo viewable $Priv(postedMb)]} {
	grab -global $Priv(postedMb)
    } else {
	while {[$menu cget -type] eq "normal" \
		&& [winfo class [winfo parent $menu]] eq "Menu" \

Changes to tests/menu.test.

3873
3874
3875
3876
3877
3878
3879





























3880
3881
3882
3883
3884
3885
3886
    # On Linux the following used to panic
    # It now returns an error (on all platforms)
    menu .m -type menubar
    list [catch ".m post 1 1" msg] $msg
} -cleanup {
    destroy .m
} -result {1 {a menubar menu cannot be posted}}































# cleanup
imageFinish
deleteWindows
cleanupTests
return







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
    # On Linux the following used to panic
    # It now returns an error (on all platforms)
    menu .m -type menubar
    list [catch ".m post 1 1" msg] $msg
} -cleanup {
    destroy .m
} -result {1 {a menubar menu cannot be posted}}

test menu-38.1 {Can't dismiss ttk::menubutton menu until mouse has hovered over it - bug fa32290898} -setup {
} -body {
    toplevel .top
    ttk::menubutton .top.mb -text "Some menu";
    menu .top.mb.m;
    .top.mb.m add command -label "Item 1";
    .top.mb.m add command -label "Item 2";
    .top.mb configure -menu .top.mb.m;
    pack .top.mb
    update
    # simulate mouse click on the menubutton, which posts its menu
    event generate .top.mb <ButtonPress-1> -warp 1
    update
    after 50
    event generate .top.mb <ButtonRelease-1>
    update
    # simulate mouse click on the menu again, i.e. without
    # entering/leaving the posted menu
    event generate .top.mb <ButtonPress-1>
    update
    after 50
    event generate .top.mb <ButtonRelease-1>
    update
    # the menu shall have been unposted by the second click
    winfo ismapped .top.mb.m
} -cleanup {
    destroy .top.mb.m .top.m .top
} -result {0}


# cleanup
imageFinish
deleteWindows
cleanupTests
return