82.md at [d8068f537b]

Login

File tip/82.md artifact fd622ded16 part of check-in d8068f537b


# TIP 82: Add -offrelief Option to Checkbutton and Radiobutton
	Author:		D. Richard Hipp <[email protected]>
	State:		Final
	Type:		Project
	Vote:		Done
	Created:	10-Jan-2002
	Post-History:	
	Tcl-Version:	8.4
-----

# Abstract

This TIP proposes adding option _-offrelief_ to the checkbutton and
radiobutton widgets to specify the relief of the widget when
_-indicatoron_ 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.

# Rationale

The checkbutton and radiobutton widgets both support the
_-overrelief_ option which is suppose to provide the capability to
change the relief of the widget on mouse-over.  The _-overrelief_
option is not used by the underlying C code.  The value of
_-overrelief_ is used only by the script bindings to change the
_-relief_ option in response to _<Enter>_ and _<Leave>_ events.
But with the checkbutton and radiobutton widgets, the value of
_-relief_ is ignored when _-indicatoron_ is turned off.  Hence,
_-overrelief_ has no effect when _-indicatoron_ is off.

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 \(_-relief_
flat\) but raise up on mouseover \(_-overrelief_ raised\).  Toolbar
buttons do not show indicators \(_-indicatoron_ off\).  This last
configuration option is the crux of the problem since when
_-indicatoron_ 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.

# Proposed Enhancement

This TIP proposes to modify the checkbutton and radiobutton widgets to
support a _-offrelief_ option.  _-offrelief_ will take any of the
usual relief values.  The default value will be _raised_.  The
_-offrelief_ option determines the relief of the widget when
_-indicatoron_ option is off and the button itself is off.

The default bindings for checkbuttons and radiobuttons will also need
to be changed so that they copy the value of _-overrelief_ into
_-offrelief_ instead of into _-relief_ when the value of
_-indicatoron_ is false.

When _-indicatoron_ is off and the button itself is on, the relief
continues to be hard-coded to sunken.  For symmetry, we might consider
adding another _-onrelief_ option to cover this case.  But it is
difficult to imagine ever wanting to change the value of _-onrelief_
so it has been omitted from this TIP.  If there as strong desire to
have _-onrelief_, it can be added later.

# Alternative Proposals

A simpler solution would be to change the _-indicatoron_ option so
that it causes the off-relief to come from the _-relief_ option
instead of using a hard-coded _raised_ relief.  That approach is
conceptually simpler, but it breaks backwards compatibility and so
must be rejected.

Another possibility is to modify _-indicatoron_ so that it takes a
third value \(other than _on_ or _off_\) where the third value works
like _off_ but takes the off-relief from the _-relief_ option
instead of always using _raised_.  But this second idea seems more
contrived and makes it more difficult to define an alternative
on-relief value with a later modification.

# Copyright

This document has been placed in the public domain.