TIP #82: Add -offrelief Option to Checkbutton and Radiobutton


TIP:82
Title:Add -offrelief Option to Checkbutton and Radiobutton
Version:$Revision: 1.4 $
Author:D. Richard Hipp <drh at hwaci dot com>
State:Final
Type:Project
Tcl-Version:8.4
Vote:Done
Created:Thursday, 10 January 2002

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.


Powered by Tcl[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]

TIP AutoGenerator - written by Donal K. Fellows