summaryrefslogtreecommitdiffstats
path: root/library/menu.tcl
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2022-07-25 17:23:15 (GMT)
committerfvogel <fvogelnew1@free.fr>2022-07-25 17:23:15 (GMT)
commitbf89b51bf772311354dc82c040d95b2718a96bc3 (patch)
tree3ea5119c93022ca4bcc0de58e66c2ed8de3394e0 /library/menu.tcl
parente81f80fe7d753638aea248799c76023827d66f04 (diff)
parent887d17ec286ccdec5fcd757986a4222429bfd040 (diff)
downloadtk-bf89b51bf772311354dc82c040d95b2718a96bc3.zip
tk-bf89b51bf772311354dc82c040d95b2718a96bc3.tar.gz
tk-bf89b51bf772311354dc82c040d95b2718a96bc3.tar.bz2
Fix [a3b03f41fe]: Wrong menu position for ttk menubutton with -style.
Diffstat (limited to 'library/menu.tcl')
-rw-r--r--library/menu.tcl32
1 files changed, 17 insertions, 15 deletions
diff --git a/library/menu.tcl b/library/menu.tcl
index 821725a..ba7acf1 100644
--- a/library/menu.tcl
+++ b/library/menu.tcl
@@ -285,7 +285,7 @@ proc ::tk::MbPost {w {x {}} {y {}}} {
GenerateMenuSelect $menu
update idletasks
- if {[catch {PostMenubuttonMenu $w $menu} msg opt]} {
+ if {[catch {PostMenubuttonMenu $w $menu $x $y} msg opt]} {
# Error posting menu (e.g. bogus -postcommand). Unpost it and
# reflect the error.
MenuUnpost {}
@@ -1132,7 +1132,7 @@ proc ::tk::MenuFindName {menu s} {
# side. On other platforms the entry is centered over the button.
if {[tk windowingsystem] eq "aqua"} {
- proc ::tk::PostMenubuttonMenu {button menu} {
+ proc ::tk::PostMenubuttonMenu {button menu cx cy} {
set entry ""
if {[$button cget -indicatoron]} {
set entry [MenuFindName $menu [$button cget -text]]
@@ -1157,14 +1157,14 @@ if {[tk windowingsystem] eq "aqua"} {
right {
incr x [winfo width $button]
}
- default {
+ default { # flush
incr x [expr {[winfo width $button] - [winfo reqwidth $menu] - 5}]
}
}
PostOverPoint $menu $x $y $entry
}
} else {
- proc ::tk::PostMenubuttonMenu {button menu} {
+ proc ::tk::PostMenubuttonMenu {button menu cx cy} {
set entry ""
if {[$button cget -indicatoron]} {
set entry [MenuFindName $menu [$button cget -text]]
@@ -1195,22 +1195,24 @@ if {[tk windowingsystem] eq "aqua"} {
set entry {}
}
left {
- # It is not clear why this is needed.
- if {[tk windowingsystem] eq "win32"} {
- incr x [expr {-4 - [winfo reqwidth $button] / 2}]
- }
incr x [expr {- [winfo reqwidth $menu]}]
}
right {
incr x [expr {[winfo width $button]}]
}
- default {
- if {[$button cget -indicatoron]} {
- incr x [expr {([winfo width $button] - \
- [winfo reqwidth $menu])/ 2}]
- } else {
- incr y [winfo height $button]
- }
+ default { # flush
+ if {[$button cget -indicatoron]} {
+ if {$cx ne ""} {
+ set x [expr {$cx - [winfo reqwidth $menu] / 2}]
+ set l [font metrics [$menu cget -font] -linespace]
+ set y [expr {$cy - $l/2 - 2}]
+ } else {
+ incr x [expr {([winfo width $button] - \
+ [winfo reqwidth $menu])/ 2}]
+ }
+ } else {
+ incr y [winfo height $button]
+ }
}
}
PostOverPoint $menu $x $y $entry