\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#42: Add New Standard Tk Option: -clientdata}
\date{July 05, 2001}
\author{Bryan Oakley}
\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 \#42}&\textbf{Add New Standard Tk Option: -clientdata}\\\hline
Author&

Bryan Oakley \tipmail{boakley}{austin.rr.com}
\\
Created&Thursday, \(\text{5}^{\text{th}}\) July 2001\\
Type&Project\\
Tcl Version&\(8.5\)\\
State&Withdrawn\\
Vote&Pending\\
Version&\tipversion$Revision: 1.4 $\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP proposes to add a new standard option, -clientdata, for all Tk widgets.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

Many modern and not so modern widget toolkits provide a way to attach programmer defined data to a widget. Tk lacks such a feature. The only way to accomplish a similar feat today is by storing data in a global or namespace variable keyed by widget name. This doesn't lend itself very well to general purpose library routines.

One example of how this could be used is in prototyping additional widget functionality. For example, \cite{tip39} requests a new option for each widget that enables a widget to declare that it is part of a larger compound widget. One potential use of this new flag is in the Tk library code that handles keyboard traversal.

With the option proposed in this TIP, it would have been quite simple to prototype the necessary changes at the script level, making it easier to validate the utility of the requested change in TIP \#39, and to provide a reference implementation of the affected library procedures.

Another example use of this flag would be in the development of a graphical interface builder such as SpecTcl or Visual Tcl. With applications that let you create widgets interactively, it is often convenient to attach metadata directly to the widget. For example, the tool might allow a user to enter comments about a given widget; or, perhaps the tool provides a way to clone a widget and wants to maintain the relationship by storing the name of the original widget. It seems to make sense to keep this information with the actual widget rather than in a global array.

A third example is that a widget or dialog could use this field to store history information. For example, a file selection dialog could remember the last directory it visited. An entry widget could remember previous values for some sort of undo functionality. Individual widgets could keep their default and most recent values to support ``revert'' or ``default'' buttons in a form.

... and the list goes on. The bottom line is, it adds flexibility that can be leveraged in many ways. Impact on the core is minimal since it merely requires the storage and retrieval of information. And the mechanism is already in place; we merely need to define a slot in the widget data structure to store the information.

\section{Specification}

Suggested wording for the \textit{options} man page (which, I suspect, can be greatly improved upon):
\begingroup\small\begin{verbatim}
 Command-Line Name: -clientdata
 Database Name: clientData
 Database Class: ClientData
\end{verbatim}
\endgroup

\begin{quote}
\textit{Specifies programmer defined data to be associated with the widget. The Tk libraries do not use this information or require the information to be in any particular format. It is purely for use by the application.}
\end{quote}

\section{Lame Joke}

Did you hear the one about the three legged dog that went into a saloon, jumped up on the nearest stool, banged his good foot on the bar, and with a steely-eyed glare said ``I'm lookin' for the man that shot my Paw!''?

\section{Notice of Withdrawal}

This TIP was Withdrawn by the TIP Editor following discussion on the tcl-core mailing list. The following is a summary of reasons for withdrawal:

\begin{quote}
Perhaps some of the ideas behind these TIPs should be incorporated into some new TIP on making megawidget support better, but none of these TIPs really stand on their own. (38 isn't a good idea, since alteration of the bindtags for all widgets of a class at once is a bad idea, and it is better when rolling your own megawidget classes to put the setting up of the bindtags in there. 39 and 42 just clash with each other as soon as you have two different codebases trying to use a single widget.)
\end{quote}

\section{Copyright}

This document has been placed in the public domain accompanied with only a small and very personal amount of fanfare.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\begin{thebibliography}{TIP \#1}
\addcontentsline{toc}{section}{References}
\bibitem[TIP \#39]{tip39}
Bryan Oakley,
\emph{Add New Standard Tk Option: -component},
on-line at \url{http://purl.org/tcl/tip/39.html}
\end{thebibliography}
\end{document}
