Selection is used to mark one or more of a group of elements simply for highlighting the elements, or so they can be moved, copied, or otherwise manipulated by the application.
Groups of elements can be organized into the following three types of collections:
In list-like collections, when the pointer or location cursor is in the collection, the pointer or location cursor is considered to be on an element.
In text-like collections, when the pointer or location cursor is in the collection, the pointer or location cursor is considered to be between two elements. The name "text-like" refers to Text components in insert mode where the insertion cursor is always between two letters. List-like and text-like collections are usually ordered as linear collections; that is, the collections are treated as if the elements were connected as a series of elements in one dimension.
In graphics-like collections, the pointer and location cursor can be either on or between elements. Graphics-like collections are usually ordered as 2-dimensional collections. That is, the ordering of elements in the collection depends on both the horizontal and vertical position of the element within each collection.
The notion of "on" depends on the manipulation model presented by the control. For example, "on" can mean that the cursor is within the bounds of the element, or it can mean that the cursor is on the boundary of the element, or the element can have handles, and "on" means that the cursor is on one of the handles.
OSF/Motif compliant systems must support the five different selection models. Each model is used where appropriate in applications to limit the type of selections the user can make. For example, a List can limit selection to a single element where the user is only allowed to make one choice. The five selection models are as follows:
The choice of the selection model should be made on a collection-by-collection basis. Some components, like Text, enforce a selection model. Other components, like a List, allow the application or the user to determine the selection model.
Variants of these selection models may be needed for collections that are especially dense, when elements are organized in layers, when 3-dimensional selection is needed, when elements are hierarchically organized, or in other situations not covered by this guide. Selection models for such cases should not deviate unnecessarily from the standard selection models.
In all selection models, the selected element or group of elements should be visually highlighted in some way. Highlighting the selection can be done in the following ways:
The selection can also be an empty selection; that is, it is
possible for no items to be selected in a collection. This commonly
occurs in text-like collections where the location cursor is between
two elements, or when the user has deselected all the elements.
Mouse-Based Single Selection
The single selection model is the simplest selection model. In the
single selection model, when BSelect
is clicked in a deselected element, the location cursor must move to
that element, that element must be selected, and any other selection
in the collection must be deselected.
Mouse-Based Browse Selection
The browse selection model is very similar to the single selection
model. In browse selection, like single selection, only a single
element is selected at a time. In the browse selection model, when BSelect
is released in a selectable element, that element must be selected,
and any other selection in the collection must be deselected. As BSelect
is dragged through selectable elements, each element under the pointer
must be selected, and the previously selected element must be
deselected. The selection must remain on the element where BSelect
is released, and the location cursor must be moved there. The browse
selection model gives the application an opportunity to provide
information about each element as it is highlighted.
Mouse-Based Multiple Selection
Multiple selection allows the user to select or deselect multiple single elements of a collection. Clicking BSelect on an unselected element must add that element to the current selection in the collection. Clicking BSelect on a selected element must remove that element from the current selection in the collection. Clicking BSelect on an element must move the location cursor to that element.
With multiple selection, the user can select any group of elements
in a collection, including discontiguous groups, all the elements, or
none of the elements. Because multiple selection requires one mouse
click for each element selected, although a simple model, it is not
well-suited for selecting large groups of elements. BSelect
Motion
can optionally toggle a range of elements. (See Mouse-Based Discontiguous Selection for a description
of range toggling.)
Mouse-Based Range Selection
The range selection model allows the user to select multiple contiguous elements of a collection. The description of this selection model assumes that drag and drop is not integrated with selection. Integrating dragging and selection is described in Transfer Models.
In the range selection model, pressing BSelect must set an anchor on the element, or at the position where BSelect was pressed, and must deselect all elements in the collection. The anchor and the current position of the pointer determine the current range. As BSelect is dragged through the collection, the current range must be highlighted. When BSelect is released, the anchor must not move, and all the elements within the current range must be selected.
In text-like collections, elements are ordered linearly, and a text pointer is always considered to be between elements at a point near the actual pointer position. The anchor point must be the text pointer position when BSelect is pressed, and the current range must consist of all elements between the anchor point and the current text pointer position.
In graphics-like and list-like collections, a marquee, or highlighted rectangle, is typically used to indicate the current range of the selection. The current range must consist of those elements that fall completely within the marquee. If a marquee selection is started when the pointer is on an element, that element can be used as an anchor element, and should be used as an anchor element if the collection is arranged as a list or matrix. If there is an anchor element, the marquee must always be made large enough to completely enclose it. Otherwise, an anchor point is used, which must be the point at which BSelect was pressed, and must determine one corner of the marquee. If the collection is arranged as a list or matrix, and the pointer is on an element, the marquee should be extended to completely enclose the element under the pointer. Otherwise, the marquee must be extended to the pointer position.
Marquee selection can be implemented so that it is used only when BSelect is pressed in the background; other selection models, not described in this style guide, can be used when BSelect is pressed on an element. If marquee selection is used, even if only when started in the background, clicking BSelect on a selectable element must make it an anchor element, select it, and deselect all other elements.
The user can extend the range selection using BSelect.
When
BSelect
is pressed, the anchor remains unchanged, and an extended range for
the selection is determined, based on one of the following extension
models:
As BSelect
is dragged through the collection, the extended range should be
highlighted, and selected elements outside of it should be
dehighlighted. When BSelect
is released, the anchor must not move, all the elements within the
extended range must be selected, and all the elements outside of it
must be deselected.
Text-like collections should use the balance beam model. The extension model used by other collections depends on the purpose of the collection.
In the range selection model, clicking BSelect
should move the location cursor to the position of the pointer without
affecting the current selection.
Mouse-Based Discontiguous Selection
The discontiguous selection mechanism allows the user to make multiple
simultaneous range selections. It is an extension of the range
selection model. The description of this selection model assumes that
drag and drop is not integrated with selection. Integrating dragging
and selection is described in Transfer
Models.
The behavior of BSelect
in the discontiguous selection model must be exactly the same as in
the range selection model, and after setting the anchor with BSelect,
BSelect
must work exactly as in the range selection model.
The primary difference between the range selection model and the
discontiguous selection model is the use of BSelect.
In the range selection model,
BSelect
is only used to move the position of the location cursor without
disrupting the current selection. In the discontiguous model,
BSelect
is used to toggle the selection state of an element or a range of
elements.
If the current selection is empty, BSelect
Click
can simply move the location cursor, but leave the anchor alone and
leave all elements deselected. Otherwise, if
BSelect
is clicked, the anchor and location cursor must move to that point,
and if
BSelect
is clicked on an element, the selection state of that element must be
toggled, and that element must become the anchor element.
BSelect
Motion
must be used to toggle the selection state of a range of elements.
The range itself must be determined exactly as for BSelect
Motion.
Releasing
BSelect
must toggle the selection state of the elements in the range according
to one of two models:
As BSelect
is dragged through the collection, highlighting should be used to
indicate the current range and the selection state of each element
that would result from releasing
BSelect
at the current position.
After using BSelect
to toggle a selection,
BSelect
or
BSelect
must be able to be used to extend the range of toggled elements. The
extended range must be determined in exactly the same way as when
BSelect
is used to extend a range selection.
When
BSelect
is released, the selection state of elements added to the range must
be determined by the toggle model as previously described. If
elements are removed from the range, they must either revert to their
state prior to the last use of
BSelect,
or change to the state opposite from the elements remaining within the
extended range.
As BSelect
or
BSelect
is dragged through the collection, highlighting should be used to
indicate the current range and the selection state of each element
that would result from releasing
BSelect
or
BSelect
at the current position.
Keyboard Selection
Selections can be made by using the keyboard as well as the mouse. Two keyboard selection models are available: normal mode and add mode.
Normal mode is used for making simple
contiguous selections from the keyboard. Normal mode is a
navigation/selection mode where the location cursor is never disjoint
from the current selection. In collections where the location cursor
is on an element, the element with the location cursor is ordinarily
selected; if it is not, pressing [Select] or moves the selection to the cursored element.
Add mode is used for making more complex and possibly disjoint selections. Add mode is a navigation/selection mode where the location cursor can move independent of the current selection. Even in collections that do not support discontiguous selections, add mode allows the selection to be unaffected by keyboard navigation.
Browse selections must only support normal mode. Single and
multiple selections must only support add mode. Range selection must
support normal mode and can also support add mode. Discontiguous
selections must support both modes. The default mode for range and
discontiguous selections must be normal mode.
must switch
between add mode and normal mode if both modes are supported. When
switching from normal to add mode, if the cursored element is the only
element selected in the collection, it should be deselected.
Mouse-based selection must not change based on the keyboard selection
mode.
In editable components, add mode is a temporary mode that must be
exited when an operation is performed on the selection or when the
selection is deselected.
Keyboard-Based Single Selection
Collections using the single selection model must use add mode. In
add mode, the navigation keys for the collection must move the
location cursor independent from the selected element. If
[Select] or is pressed
on an unselected element, it must select the element with the location
cursor, and it must deselect any previous selection in the collection.
Keyboard-Based Browse Selection
Collections using the browse selection model must use normal mode.
The navigation keys must move the location cursor and select the
cursored element, deselecting any other element. If the application
has deselected all elements or if the cursor is left disjoint from the
selection, [Select] or
must select the cursored element and deselect any other element.
Keyboard-Based Multiple Selection
Collections using the multiple selection model must use add mode.
The navigation keys for the collection must move the location cursor
independent from the current selection. [Select] or
on an unselected element must add the
element to the current selection. [Select] or
on a selected element must remove the
element from the current selection.
Keyboard-Based Range Selection
Collections using the range selection model must initially use normal mode. This allows a keyboard-based behavior similar to dragging with the mouse.
In normal mode, navigation keys must move the location cursor and deselect the current selection. If the cursor is on an element, it must be selected. The anchor must move with the location cursor. However, in text-like collections, a different model can be used in which the anchor must instead remain at its current location, except that, if the current selection is not empty, it must be deselected and the anchor must be moved to the location of the cursor prior to navigation.
[Select] or (except
in a Text component) must move the anchor to the cursor, deselect the
current selection, and, if the cursor is on an element, select the
element. Unless the anchor is on a deselected item,
[Select] or
(except in
Text) must extend the selection from the anchor to the cursor, based
on the extension model used by
BSelect.
Using in conjunction with the
navigation keys must extend the selection, based on the extension
model used by
BSelect.
If the current selection is empty, the anchor must first be moved to
the cursor. The cursor must then be moved according to the navigation
keys, and the selection must be extended based on the extension model
used by
BSelect.
In add mode, [Select], ,
[Select], and
must work exactly as in normal
mode. However, ordinary navigation must simply move the location
cursor, but must leave the anchor unchanged. Shifted navigation must
move the location cursor according to the navigation keys, and the
selection must be extended based on the extension model used by
BSelect.
In Text, both and
must insert a
space character.
Keyboard-Based Discontiguous Selection
Collections using the discontiguous selection model must initially use normal mode. In the discontiguous selection model, add mode is not only a separate model of interaction but also an extension to the range selection model that allows the user to select discontiguous elements.
In normal mode, all keyboard operations must have the same effect as in the range selection model. In normal mode, discontiguous selections cannot be made using the keyboard.
In add mode, [Select] or must move the anchor to the location cursor
and initiate toggling. If the location cursor is on an element, the
selection state of that element must be toggled, but the selection
state of all other elements must remain unchanged.
[Select] or
and shifted
navigation operations must extend the selection between the anchor and
the location cursor, based on the toggle mechanism used by
BSelect.
Canceling a Selection
must cancel or undo any incomplete
motion operation used for selection. Once
is pressed to cancel a motion operation,
the application must ignore subsequent key and button releases until
after all buttons and keys are released.
during a range selection should leave all
elements, except possibly for the cursored element, deselected.
while extending or toggling must leave the
selection state of all elements as they were prior to the button
press.
Autoscrolling and Selection
If the user drags the pointer out of a scrollable collection during
a motion-based selection operation, autoscrolling must be used to
scroll the collection in the direction of the pointer. If the user
presses with BSelect
pressed, the selection operation must be canceled as described in Canceling a
Selection.
Selecting and Deselecting All Elements
There are two special keyboard-based selection mechanisms for
selecting (via [/] )
and deselecting (via
[\] ) all the elements in a collection.
[/] in a collection using
multiple, range, or discontiguous selection must select all the
elements in a collection, place the anchor at the beginning of the
collection, and leave the location cursor at its previous position.
Deselection differs between add mode and normal mode. In add mode,
[\] must deselect all
the elements in a collection. In normal mode,
[\] must deselect all the
elements in a collection, except the element with the location cursor
if the location cursor is being displayed. In either case, it must
leave the location cursor at its current location and move the anchor
to the location cursor. An application can deselect all elements in a
collection regardless of the state of add mode or the selection model.
Using Mnemonics for Elements
Collections can also support mnemonics
associated with its elements if the elements have labels. Pressing a
mnemonic key while the collection has the keyboard focus must be
equivalent to moving the location cursor to the element and pressing
[Select] or .