diff options
author | fvogel <fvogelnew1@free.fr> | 2016-08-29 15:45:33 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2016-08-29 15:45:33 (GMT) |
commit | 1873b2da08408228b8b139ed92785a2f9c048b3b (patch) | |
tree | a7b95f331953f40a0034199e4889177b9a544840 | |
parent | d1ffebb971d9a844511bf96c8c734b96c0b75424 (diff) | |
parent | 1e6f41e17ea6b546ea891d57ed147b09a8c2f7cd (diff) | |
download | tk-1873b2da08408228b8b139ed92785a2f9c048b3b.zip tk-1873b2da08408228b8b139ed92785a2f9c048b3b.tar.gz tk-1873b2da08408228b8b139ed92785a2f9c048b3b.tar.bz2 |
Fixed [fa32290898] - Can't dismiss ttk::menubutton menu until mouse has hovered over it
-rw-r--r-- | library/menu.tcl | 4 | ||||
-rw-r--r-- | tests/menu.test | 29 |
2 files changed, 33 insertions, 0 deletions
diff --git a/library/menu.tcl b/library/menu.tcl index a7aaa3f..b5dd88e 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -607,6 +607,10 @@ proc ::tk::MenuButtonDown menu { 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) diff --git a/tests/menu.test b/tests/menu.test index aaadc86..a97aa25 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -3878,6 +3878,35 @@ test menu-37.1 {menubar menues cannot be posted - bug 2160206} -setup { 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 |