Updated 2014-04-03 02:50:55 by RLE

On comp.lang.tcl, someone asked:

With reference to a TK listbox widget, what is the difference between the terms: "active" and "selected"?

A:

A listbox with -selectmode "multiple" or "extended" can have any number of "selected" items, and at most one "active" item. Most keyboard bindings operate on the "active" item. For instance, the up and down arrow keys change the "active" item, and the spacebar toggles whether the active item is selected or not.

With -selectmode "browse" (the default), the active item is always the (sole) selected item, and since listboxes don't acquire the keyboard focus by default, you won't see a location cursor unless you traverse to the listbox with <Key-Tab>. So the "active" item frequently isn't visually distinguishable.

The distinction is easiest to see with a listbox that has keyboard focus and -selectmode multiple. Try this:
 pack [listbox .l -selectmode multiple]
 .l insert end asdf qwerty uiop foo
 focus .l