<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://www.tcl.tk/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Sat May 25 08:11:42 GMT 2013 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='349'>
<header><title>New &quot;-cargo&quot; option for every Tk widget</title><author address="mailto:zb@ispid.com.pl">Zbigniew Baniewski</author><status type='project' state='draft' tclversion="8.7" vote='prior'>$Revision: 1.1 $</status><history></history><created day='17' month='apr' year='2009' /></header>
<abstract>This TIP proposes adding a <emph style="bold">-cargo</emph> option to every Tk widget that will be kept free for code that uses the widget to use as it sees fit; the Tk library will assign no interpretation to the option.</abstract>
<body><section title="Proposal">
<para>TCL users have long been at a disadvantage not having a possibility to attach arbitrary widget-related values (e.g., &quot;tooltip&quot;-texts) directly to widget, being forced to use workarounds (e.g. external variables to hold the data) or even entire additional packages/frameworks (like Snit) exactly because of the lack of the proposed option.</para>
<para>So the proposal is &quot;solutions instead of workarounds&quot;: let&apos;s introduce the option - further named &quot;-cargo&quot; (the name taken from Clipper) - which will cancel the current need for fixes of different kind. The option should allow to access a string field (or even better: a dictionary), allowing to keep there any widget-related data, choosen by script creator. It&apos;s value should be accessible both by &quot;cget&quot; and &quot;percent substitution&quot; (like &quot;%C&quot;).</para>
</section>
<section title="Rationale">
<para>In a talk at <url ref="news:comp.lang.tcl"/> everyone - or almost everyone - posting in the appropriate threads, appreciated the proposed solution as useful. There were some fears about possible &quot;clashes&quot; while using that option (or that the proposed option will be even &quot;too useful&quot;). I would to mention here, that &quot;cargo&quot; idea has been taken from Clipper, where - during over 20 past years - there is no evidence at all of any &quot;clashes&quot; (neither of any other damage) only because of availability of such option. Being sure, that TCL programmers aren&apos;t less skilled than those Clipper guys, I cannot describe such fears differently, than as not reasonable ones.</para>
<para>So because such option has been successfully tested in other language (there are no complaints from Clipper programmers about any &quot;cargo&quot;-harmness), there&apos;s no need for &quot;prophecies&quot; of the type &quot;it will do damage&quot;, because there has been proved exactly the contrary.</para>
<para>Some more possible usage gave Bryan Oakley in his post:</para>
<quote>What sort of data would I potentially keep with a widget? Perhaps an index that points to context sensitive help. Or, I might keep an undo stack, or a copy of the original value. Think of a label widget that automatically truncates it&apos;s text and adds &quot;...&quot; if the widget is resized smaller than it&apos;s preferred size -- you need to keep the unadulterated original value that you can refer to as the widget grows and shrinks. Better to keep that with the widget than in a global variable, IMO. Or, I could use it to keep track of a &quot;dirty&quot; bit that gets set when the original value of a radiobutton or checkbutton changes. Or I could store a database primary key that points to where the data for the widget came from.</quote>
<para>I believe, that&apos;s not all, because we cannot predict today, what other useful things can be done with option of such &quot;universal&quot; (not &quot;targetted&quot;) nature. Two things for sure: a) It&apos;ll make the life of every TCL-scriptor easier, b) Its use won&apos;t be obligatory, if someone will be afraid of &quot;clashes&quot; possibility, or something like this.</para>
</section>
<section title="License">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>
