From 24e47b1d059cf68f776b57faf187e4e022ad2a13 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 19 Aug 2016 20:31:26 +0000 Subject: Fixed [fa32290898] - Can't dismiss ttk::menubutton menu until mouse has hovered over it --- library/menu.tcl | 4 ++++ 1 file changed, 4 insertions(+) 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) -- cgit v0.12 From 6fb89b6069a9896acc6a2dc61f6b4f86e1b4e92c Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 19 Aug 2016 21:47:34 +0000 Subject: Fixed [2cf3d6942c] - Test button-5.24 fails. First, use {Helvetica -12} as font for the button text instead of {Helvetica -12 bold} since it's the former and not the latter that is tested against in constraints.tcl regarding the 'font' constraint. Second, don't force -width to a fixed value, otherwise width results can be wrong. Third, adjust the test results in width according to the two previous changes. --- tests/button.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/button.test b/tests/button.test index 708fc30..194e877 100644 --- a/tests/button.test +++ b/tests/button.test @@ -3435,15 +3435,15 @@ test button-5.23 {ConfigureButton - -height option} -constraints { test button-5.24 {ConfigureButton - computing geometry} -constraints { fonts } -body { - button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} - .b configure -text "Sample text" -width 10 -height 2 + button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} + .b configure -text "Sample text" -height 2 pack .b set result "[winfo reqwidth .b] [winfo reqheight .b]" .b configure -bitmap questhead lappend result [winfo reqwidth .b] [winfo reqheight .b] } -cleanup { destroy .b -} -result {104 46 20 12} +} -result {96 46 30 12} test button-5.25 {ConfigureButton - computing geometry} -setup { button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} -- cgit v0.12 From d27dd9b903416ca1a90206b913495225ac79133c Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 23 Aug 2016 18:27:14 +0000 Subject: Improved further test button-5.24: the test no longer depends on default values for -padx and -pady and it now computes the expected size of the button --- tests/button.test | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/tests/button.test b/tests/button.test index 194e877..d4db317 100644 --- a/tests/button.test +++ b/tests/button.test @@ -3435,15 +3435,47 @@ test button-5.23 {ConfigureButton - -height option} -constraints { test button-5.24 {ConfigureButton - computing geometry} -constraints { fonts } -body { - button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} - .b configure -text "Sample text" -height 2 + button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ + -padx 30 -pady 20 + # 1. button with text + .b configure -text "Sample text" pack .b - set result "[winfo reqwidth .b] [winfo reqheight .b]" - .b configure -bitmap questhead - lappend result [winfo reqwidth .b] [winfo reqheight .b] -} -cleanup { - destroy .b -} -result {96 46 30 12} + set textwidth [font measure [.b cget -font] -displayof .b [.b cget -text]] + set expectedwidth [expr {$textwidth + 2*[.b cget -borderwidth] \ + + 2*[.b cget -highlightthickness] + 2*[.b cget -padx]}] + incr expectedwidth 2 ; # added (hardcoded) in tkUnixButton.c + set result [expr $expectedwidth == [winfo reqwidth .b]] + set linespace [lindex [font metrics [.b cget -font] -displayof .b] 5] + set expectedheight [expr {$linespace + 2*[.b cget -borderwidth] \ + + 2*[.b cget -highlightthickness] + 2*[.b cget -pady]}] + incr expectedheight 2 ; # added (hardcoded) in tkUnixButton.c + lappend result [expr $expectedheight == [winfo reqheight .b]] + # 2. button with a bitmap image + # there is no access to characteristics the predefined bitmaps, + # so define one as an image (copied from questhead.xbm) + set myquesthead [image create bitmap -data { + #define myquesthead_width 20 + #define myquesthead_height 22 + static unsigned char myquesthead_bits[] = { + 0xf8, 0x1f, 0x00, 0xac, 0x2a, 0x00, 0x56, 0x55, 0x00, 0xeb, 0xaf, 0x00, + 0xf5, 0x5f, 0x01, 0xfb, 0xbf, 0x00, 0x75, 0x5d, 0x01, 0xfb, 0xbe, 0x02, + 0x75, 0x5d, 0x05, 0xab, 0xbe, 0x0a, 0x55, 0x5f, 0x07, 0xab, 0xaf, 0x00, + 0xd6, 0x57, 0x01, 0xac, 0xab, 0x00, 0xd8, 0x57, 0x00, 0xb0, 0xaa, 0x00, + 0x50, 0x55, 0x00, 0xb0, 0x0b, 0x00, 0xd0, 0x17, 0x00, 0xb0, 0x0b, 0x00, + 0x58, 0x15, 0x00, 0xa8, 0x2a, 0x00}; + }] + .b configure -image $myquesthead + set expectedwidth [expr {[image width $myquesthead] + 2*[.b cget -borderwidth] \ + + 2*[.b cget -highlightthickness]}] + incr expectedwidth 2 ; # added (hardcoded) in tkUnixButton.c + lappend result [expr $expectedwidth == [winfo reqwidth .b]] + set expectedheight [expr {[image height $myquesthead] + 2*[.b cget -borderwidth] \ + + 2*[.b cget -highlightthickness]}] + incr expectedheight 2 ; # added (hardcoded) in tkUnixButton.c + lappend result [expr $expectedheight == [winfo reqheight .b]] +} -cleanup { + destroy .b +} -result {1 1 1 1} test button-5.25 {ConfigureButton - computing geometry} -setup { button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} -- cgit v0.12 From 1e6f41e17ea6b546ea891d57ed147b09a8c2f7cd Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 23 Aug 2016 19:30:19 +0000 Subject: Added non regression test case menu-38.1 --- tests/menu.test | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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 -warp 1 + update + after 50 + event generate .top.mb + update + # simulate mouse click on the menu again, i.e. without + # entering/leaving the posted menu + event generate .top.mb + update + after 50 + event generate .top.mb + 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 -- cgit v0.12 From 3f31a49af5095bb916f325335fefc3a101c687fe Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 29 Aug 2016 17:42:45 +0000 Subject: 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 --- tests/menu.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/menu.test b/tests/menu.test index a97aa25..05356e3 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -3879,7 +3879,7 @@ test menu-37.1 {menubar menues cannot be posted - bug 2160206} -setup { } -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 { +} -constraints {macOrUnix} -body { toplevel .top ttk::menubutton .top.mb -text "Some menu"; menu .top.mb.m; -- cgit v0.12