\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#286: Add 'xposition' Command to Menu Widgets}
\date{October 18, 2006}
\author{Schelte Bron}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#286}&\textbf{Add 'xposition' Command to Menu Widgets}\\\hline
Author&

Schelte Bron \tipmail{sbron}{wanadoo.nl}
\\
Created&Wednesday, \(\text{18}^{\text{th}}\) October 2006\\
Type&Project\\
Tcl Version&\(8.5\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.4 $\\
Keywords&Tk\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

There has been a \textbf{yposition} subcommand for menu widgets for years, but its counterpart in the x-direction does not currently exist. This TIP intends to rectify that situation.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

There is currently no way to obtain the x-position of a menu entry while a \textbf{menu} subcommand for obtaining the y-position does exist. Even though on a normal menu the x-position will always be 1, there are a few circumstances where the x-position may have some more interesting values. In particular, this is the case for menubars and for menus with column-breaks.

\section{Proposed New Command}

This TIP proposes a new subcommand for \textbf{menu} widgets, \textbf{xposition}, with the following syntax:

\begin{quote}
\textit{pathName} \textbf{xposition} \textit{index}
\end{quote}

This returns an integer giving the x-coordinate within (i.e., relative to) the menu window specified by \textit{pathName} of the leftmost pixel in the entry specified by \textit{index}. The \textit{index} may take any of the normal forms for identifying a menu entry.

\section{Reference Implementation}

Submitted to SourceForge as Patch \#1152376. [\url{http://sf.net/tracker/?func=detail&aid=1152376&group_id=12997&atid=312997}]

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\end{document}
