<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://tcl.activestate.com/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Thu Feb 09 08:41:04 GMT 2012 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='82'>
<header><title>Add -offrelief Option to Checkbutton and Radiobutton</title><author address="mailto:drh@hwaci.com">D. Richard Hipp</author><status type='project' state='final' tclversion="8.4" vote='after'>$Revision: 1.4 $</status><history></history><created day='10' month='jan' year='2002' /></header>
<abstract>This TIP proposes adding option <emph style="italic">-offrelief</emph> to the checkbutton and radiobutton widgets to specify the relief of the widget when <emph style="italic">-indicatoron</emph> is off and the state of the button is off. This feature is needed to support the use of checkbutton and radiobutton widgets on toolbars.</abstract>
<body><section title="Rationale">
<para>The checkbutton and radiobutton widgets both support the <emph style="italic">-overrelief</emph> option which is suppose to provide the capability to change the relief of the widget on mouse-over. The <emph style="italic">-overrelief</emph> option is not used by the underlying C code. The value of <emph style="italic">-overrelief</emph> is used only by the script bindings to change the <emph style="italic">-relief</emph> option in response to <emph style="italic">&lt;Enter&gt;</emph> and <emph style="italic">&lt;Leave&gt;</emph> events. But with the checkbutton and radiobutton widgets, the value of <emph style="italic">-relief</emph> is ignored when <emph style="italic">-indicatoron</emph> is turned off. Hence, <emph style="italic">-overrelief</emph> has no effect when <emph style="italic">-indicatoron</emph> is off.</para>
<para>An example of the effect we would like to achieve is the Bold/Italic/Underline and text justification toolbar buttons on word processors. The Bold/Italic/Underline toolbar buttons are most naturally implemented using Tk checkbuttons and the text justification toolbar buttons are most naturally implemented using Tk radiobuttons. The buttons are configured to be flat most of the time (<emph style="italic">-relief</emph> flat) but raise up on mouseover (<emph style="italic">-overrelief</emph> raised). Toolbar buttons do not show indicators (<emph style="italic">-indicatoron</emph> off). This last configuration option is the crux of the problem since when <emph style="italic">-indicatoron</emph> is off, the relief of the button is hard-coded to be raised when the button is on and sunken when the button is off. In the current implementation, there is no way to get the off-relief to be flat, and hence there is no way to achieve the customary look for these common toolbar buttons.</para>
</section>
<section title="Proposed Enhancement">
<para>This TIP proposes to modify the checkbutton and radiobutton widgets to support a <emph style="italic">-offrelief</emph> option. <emph style="italic">-offrelief</emph> will take any of the usual relief values. The default value will be <emph style="italic">raised</emph>. The <emph style="italic">-offrelief</emph> option determines the relief of the widget when <emph style="italic">-indicatoron</emph> option is off and the button itself is off.</para>
<para>The default bindings for checkbuttons and radiobuttons will also need to be changed so that they copy the value of <emph style="italic">-overrelief</emph> into <emph style="italic">-offrelief</emph> instead of into <emph style="italic">-relief</emph> when the value of <emph style="italic">-indicatoron</emph> is false.</para>
<para>When <emph style="italic">-indicatoron</emph> is off and the button itself is on, the relief continues to be hard-coded to sunken. For symmetry, we might consider adding another <emph style="italic">-onrelief</emph> option to cover this case. But it is difficult to imagine ever wanting to change the value of <emph style="italic">-onrelief</emph> so it has been omitted from this TIP. If there as strong desire to have <emph style="italic">-onrelief</emph>, it can be added later.</para>
</section>
<section title="Alternative Proposals">
<para>A simpler solution would be to change the <emph style="italic">-indicatoron</emph> option so that it causes the off-relief to come from the <emph style="italic">-relief</emph> option instead of using a hard-coded <emph style="italic">raised</emph> relief. That approach is conceptually simpler, but it breaks backwards compatibility and so must be rejected.</para>
<para>Another possibility is to modify <emph style="italic">-indicatoron</emph> so that it takes a third value (other than <emph style="italic">on</emph> or <emph style="italic">off</emph>) where the third value works like <emph style="italic">off</emph> but takes the off-relief from the <emph style="italic">-relief</emph> option instead of always using <emph style="italic">raised</emph>. But this second idea seems more contrived and makes it more difficult to define an alternative on-relief value with a later modification.</para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>

