Menu

#1989 tk_popup posts menu at the wrong place

obsolete: 8.4.11
closed-fixed
7
2005-12-01
2005-11-10
No

The bug occurs when tk_popup tries to post a menu at
a position that does not allow to display the full menu
height on screen.

The problem can be reproduced with this simple script
to launch in wish:

menu .m
for {set i 0} {$i<15} {incr i} {
.m add command -label "hello $i"
}
bind . <Button-1> { \ tk_popup .m \ [winfo pointerx .] \ [winfo pointery .] \ }

Enlarge or move the . window so as its lower border is
near the lower border of the screen and click button-1 in
this area.

Since the menu is too tall to fit in the screen if the first
line is placed at the cursor position, Tk computes a new
placement point of the menu.

This computation must be incorrect since the menu is
posted much too far away upwards.

Note however that the behaviour appears to be OK wrt
the right side of the screen.

This is with Tck/Tk 8.4.11.
It is OK with 8.5 alpha release.

Discussion

  • Aaron Faupell

    Aaron Faupell - 2005-11-18

    Logged In: YES
    user_id=812825

    proc tk::PostOverPoint should be changed to the following:

    global tcl_platform

    if {[string compare $entry {}]} {
    if {$entry == [$menu index last]} {
    incr y [expr {-([$menu yposition $entry] +
    [winfo reqheight $menu])/2}]
    } else {
    incr y [expr {-([$menu yposition $entry] +
    [$menu yposition [expr {$entry+1}]])/2}]
    }
    incr x [expr {-[winfo reqwidth $menu]/2}]
    }
    $menu post $x $y
    if {$entry ne "" && [$menu entrycget $entry -state]
    ne "disabled"} {
    $menu activate $entry
    GenerateMenuSelect $menu
    }

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-11-18
    • priority: 5 --> 7
    • assigned_to: tmh --> hobbs
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-12-01
    • status: open --> closed
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-12-01
    • status: closed --> closed-fixed
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-12-01

    Logged In: YES
    user_id=72656

    Backported fix that was used for 8.5, to reduce available
    screenheight by 10 in calculation. I believe that Windows
    is actually adding padding for the menu shadow.