TIP #94: Add Listbox -activestyle Option

Title:Add Listbox -activestyle Option
Version:$Revision: 1.5 $
Author:Jeff Hobbs <JeffH at ActiveState dot com>
Created:Wednesday, 29 May 2002


This TIP proposes to add a [-activestyle] option to the [listbox] widget that would control what style the active element has when the widget has focus (currently hard-coded to be underlined).


Tk has always had an underline on the active item in listboxes, which is shown when the listbox has focus. However this in incompatible with the style of listboxes on Windows, especially as used in drop-down boxes. They instead have a thin dotted line to indicate the active item. In order to improve native look and feel, we would allow the user to request the style which indicates the active item.


    $listbox configure -activestyle none|underline|dotbox

The default would be underline, which stays consistent with the current behavior. dotbox is the Windows style, which is essentially the dotted focus ring that any item with focus receives. While Windows does have a special API (DrawFocusRect) to draw this, it should be possible with the features of the dash patch to emulate on Unix. It may not be possible to draw a dotbox easily on MacOS, in which case the option will be allowed, but nothing would be drawn (rather than dropping back to underline).

Reference Implementation

This implementation is simple and would only extend one check in DisplayListbox for whether the underline should be drawn.

File: tcl/generix/tkListbox.c

Function: DisplayListbox


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