Check-in [12ab068abe]

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Added TIP 533
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 12ab068abe9da1f63db8b34f3aad96932a9eba82d9380c65c238ac1ae684ccfa
User & Date: marc_culler 2019-01-15 15:35:41
Context
2019-01-15
15:38
updated index check-in: 163cda6ada user: marc_culler tags: trunk
15:35
Added TIP 533 check-in: 12ab068abe user: marc_culler tags: trunk
2019-01-14
10:22
Minor fix in #532. check-in: 342b828704 user: gcramer tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added tip/533.md.






















































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# TIP 533: Extension of the menu post command.
	Author:         Marc Culler
	State:          Draft
	Type:           Project
	Vote:           Pending
	Created:        13-Jan-2019
	Post-History:  
	Keywords:       Tk, menubutton
	Tcl-Version:    8.6
	Tk-Branch:      bug-70e531918e
----

# Abstract

This TIP proposes to modify the menu post command by adding one optional
argument which specifies the index of a menu item.  The current command
accepts two arguments, x and y, which specify the screen coordinates where the
upper left corner of the menu should be posted.  If the proposed optional
index is provided it will mean that the upper left corner of the item with
that index should be located at the point specified by x and y.

# Rationale

Within Tk itself the menu post command is primarily used for posting a
<b>Tk_optionMenu</b>.  This widget needs to draw the menu so that the currently
selected menu item is placed on top of the widget's menuButton.  This is done
by calling <b>::tk::PostOverPoint</b> which, like the proposed extension, accepts
three arguments: two coordinates and an index.  That function uses the
previously computed menu geometry to compute a location for the upper left
corner of the menu which will result in correct positioning of the item
specified by the index argument.  It then calls the menu post command with the
computed x and y coordinates.

On Windows and macOS popup menus are drawn by the system.  Determining the
geometry of a menu on these systems involves reverse engineering, since there
is no geometry specification available.  Reverse engineering proprietary
software is necessarily subject to errors which can be avoided if it is
possible to use calls to routines provided by the system library.  As it
happens, there is such a routine available on macOS.  Apple's NSMenu object has
a method <b>[NSMenu popUpMenuPositioningItem:atLocation:inView]</b> which draws the
menu so that the upper left corner of the specified menu item is located at
the point given as the atLocation parameter.  The extension proposed in this
TIP makes it possible to conveniently use this NSMenu method within the
platform specific <b>TkpPostMenu</b> function, provided that the signature of that
function is also extended to include a third integer argument specifying the
index of the item.

This TIP arose from an attempt to fix a number of rendering bugs for
menubuttons on all platforms which were reported in ticket
[70e531918e](https://core.tcl-lang.org/tk/tktview/70e531918e6d99cbdd8b527386fec15872c64216).
Because these bugs exist in Tk 8.6.9 and because fixing them is greatly
simplified by this very small extension to Tk, this TIP is targeting version
8.6.

# Specification and documentation

  <i>pathName</i> <b>post</b> <i>x y ?index?</i>

The change consists in the addition of the optional <i>index</i>
argument. If <i>index</i> is present the menu will be posted so that 
the entry with that index is displayed at the given <i>x y</i> coordinates.
Backwards compatibility is guaranteed  since the command does not
change its behavior if this argument is omitted. The optional <i>index</i>
can be specified using any of the forms currently allowed in the
[menu man page](https://www.tcl.tk/man/tcl/TkCmd/menu.htm).

# Reference Implementation

All of the changes needed to implement this TIP are included in the leaf of
the [bug-70e531918e](https://core.tcl-lang.org/tk/timeline?r=bug-70e531918e)
branch of the Tk fossil repository.

# Copyright

This document has been placed in the public domain.