OpenStep User Interface Guidelines
  Search only this book
Download this book in PDF

User Actions: The Mouse and Keyboard

3

Chapter 2 introduced three basic paradigms--direct manipulation, targeted action, and modal tools--that guide OpenStep users when they operate windows, menus, controls and other interface objects. This chapter looks at the specific mouse and keyboard actions--clicking, double-clicking, dragging, and so on--that users perform on these objects.
Mouse Actionspage 3-2
Selecting Objects with the Mousepage 3-5
Implementing Selectionpage 3-10
Managing the Pointerpage 3-11
Mouse Actions for Custom Objectspage 3-13
Keyboard Actionspage 3-20
Implementing Keyboard Alternativespage 3-24
Implementing Modifier Key--Arrow Key Combinationspage 3-31

Mouse Actions

The mouse moves the pointer in the workspace. Users typically move the pointer to an object and then use the mouse button to act on the object.There are two basic mouse operations:
  • Moving the mouse to position the pointer. When the pointer is focused on an object, it is said to be positioned "on" or "over" the object. (With the standard arrow pointer, the point of the arrow indicates the user's point of focus; other pointer shapes have other graphic devices to indicate their points of focus.)
  • Pressing and releasing the mouse button.
From these basic operations, the standard mouse actions are derived:
  • Clicking
  • Multiple-clicking
  • Dragging
  • Pressing
Guided by the action paradigms, users can perform these mouse actions (and combinations of them) to rearrange windows, operate controls, and edit documents.

Note - The result of using App Kit objects includes recognition of appropriate mouse actions and automatic execution of the application-specific behavior you specify in action methods. The menu command object, for example, will execute its action method when clicked. You write the action method, which might open a panel or perform some other action. The text object responds to a different set of mouse actions, including clicks, double-clicks, triple-clicks, and dragging. If you create a custom control or a custom content area, you will probably need to write code to handles any mouse actions you want the control or area to respond to. This is covered later in this chapter in the sections "Actions for Custom Objects" and "Other Action Keys."

Clicking

Users click on an object by positioning the pointer over it and operating the mouse button. The mouse button is pressed and released quickly, and the mouse is not usually moved during the click. The timing of the click is generally not significant.
A click indicates that the user's attention is focused at a particular screen location. The interface's response to the click depends on the object at that location. If the object is a window, clicking on it brings it to the front and usually selects it to receive characters from the keyboard. If the object is a menu command, button, or other control, clicking on it initiates whatever application-specific action has been defined for it. In a text area, a click selects a location for the insertion point (the place where typing will begin). In a graphics editor, it may select the location for a Paste command.

Note - The OpenStep interface provides two mouse functions, Select and Menu. Select is used for clicking, double-clicking, choosing menu commands, and other operations on interface objects that are described in this chapter. Select is normally assigned to the left button (left-handed users can reverse the functions of the buttons). In this manual, which covers operating the interface, "clicking the button" and "clicking on an object" mean clicking the button that is currently performing the Select function. For more information, see "Changing the Function of the Mouse Buttons in this Chapter.

Multiple-Clicking

Users double-click an object by positioning the pointer over it and pressing and releasing the mouse button twice. The second click must be within a short interval of the first to be recognized as a double-click. (Users can adjust the time interval within which two clicks are recognized as a double-click, to suit their individual needs, with the Preferences application.) The pointer cannot move significantly during the interval between the two clicks, which ensures that the double-click is focused on a single screen location.
Users triple-click an object by rapidly pressing and releasing the mouse button three times in succession. Triple-clicks are subject to the same pointer movement and time interval constraints as double-clicks.
Some objects respond differently to single, double- and triple-clicks.

Pressing

Users press an object by positioning the pointer over it, and pressing and holding the mouse button. Some types of object, such as the arrows in a scroller, respond to pressing and begin to act as soon as the mouse button is pressed. They do not wait for the button to come back up and complete a click.
Pressing an object resembles a click because the mouse button will be released eventually. The object is said to be pressed, rather than clicked, if the action begins when the mouse button is pressed and ends when the button is released.

Dragging

Users drag by pressing the mouse button, holding it and moving the pointer with the button down. This action is most often used in direct manipulation of objects.
In general, a dragging action includes a click (since the mouse button is pressed before dragging and released after it is complete). Dragging a window, for example, will also bring it to the front, as though the user simply clicked on it. There are, however, a few situations in which objects should respond differently to dragging and clicking. These are covered in "When Dragging Should Not Imply Clicking" later in this chapter.

Mouse Responsiveness

The pointer moves when the user moves the mouse, but the relationship between the two movements is not constant. Rapid mouse movements move the pointer farther than slow ones. This feature is called mouse speed, and users can adjust it with the Preferences application.

Changing the Functions of the Mouse Buttons

OpenStep provides two mouse functions, Select and Menu. Select is used to click, double-click, and choose menu commands, and is normally assigned to the left menu button. Menu opens a copy of the active application's main menu at the pointer location, and is normally assigned to the right menu button. On a three button mouse, such as a Sun mouse, the middle button is not active, while a two button mouse uses both of its buttons.
Left-handed users may be more comfortable if they reverse these functions. They can do so with the Mouse Preferences panel in the Preferences application. (See "Bringing the Main Menu to the Pointer" in Chapter 6 for details of the Menu function.)

Selecting Objects with the Mouse

The modal tool and targeted action paradigms require users to select objects. They do so by clicking on them or by clicking and dragging. A variety of objects can be selected, including:
  • Tools in a tool palette
  • Cells in a matrix or fields in a form
  • Icons in a file viewer
  • Items in a list (of files or mail messages, for example)
  • Characters in editable text
  • Graphical elements of editable artwork
  • Position of the insertion point in text or graphics
Selecting an object distinguishes it from other objects of the same type. It does not change the selected object in any way. (It does not include such operations as clicking on a radio button or choosing a menu command.) In some cases, such as clicking on a window to bring it forward or clicking in a text area to position the insertion point, selecting is a complete operation in itself, followed by another operation such as moving to a control on the window or typing at the insertion point. But in most cases, users select an object to designate it as the target for a subsequent operation (this is the targeted-action paradigm).
In areas where users are allowed to insert new material (text, graphics, and so on), they can select objects already displayed or select a location for inserting. In a text field, for example, it is possible to select characters that have already been typed or an insertion point for more typing.
Note that windows are activated, rather than selected. Users can both activate a window and select a control or text location on it with a single mouse operation.
This rest of this discussion concentrates on selections in editable material, although the rules often apply to other kinds of selection.

Clicking to Select

If the anchor point (the pointer's location when the mouse button was pressed) and the endpoint (the pointer's location when the mouse button is released) are substantially the same, the user's action is a click. A click sometimes selects the item under the pointer and sometimes simply selects the clicked location as the insertion point for text or a modal tool. In a graphics editor, for example, a click can select an existing figure.
In text, a single click always selects a location as the insertion point, where characters can be entered from the keyboard. The insertion point is normally marked by a blinking vertical bar located between characters. If the user clicks on top of a character, the insertion point is positioned at the nearest character boundary. Clicking in a margin, or in an empty area away from any text, puts the insertion point next to the nearest character.

Multiple-Clicking to Select

A single click in a text area selects the location of the insertion point, but multiple clicks select a linguistically meaningful unit of the already existing text. Double-clicking in text normally selects a word, and triple-clicking normally selects a paragraph (defined as the text between two return characters).
If the user selects a character or word with a multiple-click and then drags, this selects additional text in the character blocks selected by the multiple-click. For example, after double-clicking to select a word, dragging after the double-click selects all other words that are even partially within the range defined by the anchor and end points of the drag.

Dragging to Select

Dragging selects everything between the anchor and end points of the drag. Exactly what is included in the selection depends on the type of material through which the pointer is dragged. See "Selection in Text and Selections in Graphics" later in this chapter for details.

Note - The App Kit supplies a text object and a browser with all of the selection mechanisms described in this section except one--the text object does not implement discontinuous selection. If you define your own selectable data, you will have to implement selection yourself, in accordance with these guidelines.

Extending a Selection

Pressing the mouse button to begin a click or drag operation normally cancels the current selection to begin a new one. But holding down either the Alt key or the Shift key modifies this action, allowing users to extend the current selection instead of canceling it.

Continuous Extension

Clicking and dragging when the Alt key is held down results in a new selection, which includes the initial selection and everything that lies between it and the pointer's final position (where the mouse button is released). The Alt key is thus an alternative to dragging as a way of selecting a range--the user can click on one location to establish an anchor point, hold down the Alt key, and click again to determine the end point.
If the initial selection is itself a range, Alt-clicking and Alt-dragging will extend one edge of the selection (the edge closest to the pointer when the mouse button goes down) to the pointer's final position (where the mouse button is released). The Alt key thus also provides a way of adjusting the boundaries of the initial selection. Alt-clicking outside a selected range extends the range to the point on which the user Alt-clicks. Alt-clicking inside a selected range repositions the closest edge of the selection to the point on which the user Alt-clicks. Refer to Figure 3-1 to see the effect of Alt-clicking.

Graphic

Figure 3-1

If the initial selection is the result of a multiple-click the Alt key extends it, just as dragging would. Double-clicking a word, holding the Alt key down, and clicking on another word elsewhere in the text extends the selection to include both words and all those between the two.

Discontinuous Extension

The Shift key lets users add to, or subtract from, the current selection. Additions do not have to be continuations of the current selection, so discontinuous selections can result.
Discontinuous selection is common for editable graphics, icons, and items arranged in a list. It is not usually implemented for normal text.
To extend a selection, the user clicks and drags as usual while holding the Shift key down. New material is selected, but the previous selection also remains. This is illustrated in the middle column of Figure 3-2.

Graphic

Figure 3-2

To subtract from the selection, the user holds the Shift key down while clicking on or dragging over some part of the current selection. Shift-clicking and Shift-dragging deselect material that has already been selected. While keeping the Shift key down, the user can first select material, then deselect it, then select it again.
Shift-dragging either selects or deselects; it never does both. Which it does depends on the status of the item under the pointer when the mouse button goes down:
  • If the item is not currently part of the selection, Shift-dragging will select it and everything the user drags over. It will not deselect material that happens already to be selected.
  • If the item is currently selected, Shift-dragging deselects it and any other selected material that is dragged over. It will not add unselected material to the selection.

How the Arrow Keys Affect a Text Selection

In a text area, the keyboard arrow keys are used to position the insertion point or, if modified by the Alt key, alter the current selection. Unlike the mouse, which can select anywhere within a document, movement by the arrow keys is only relative to the current selection. The arrow keys have nothing to do with the pointer, which is controlled only by the user's mouse movements.
The following descriptions assume that the initial selection, before the user touches an arrow key, is a range of text. The simpler case, in which the current selection is not a range but an insertion point, is not directly addressed, but it can easily be derived from the descriptions given.
  • When used alone (without a modifier key), the current selection is canceled and the insertion point moves. The left arrow key puts the insertion point one character before the beginning of the current selection. The right arrow key puts the insertion point one character beyond the end of the current selection. These keys will move the insertion point to the previous or next line if necessary.
  • The up arrow key puts the insertion point one line above the beginning of the current selection, and the down Arrow key puts it one line below the end of the current selection. As the up and down Arrow keys move it from line to line, the insertion point maintains the same approximate distance from the left margin. It falls at the end of any line that is shorter than that distance, but comes back out to the original distance when a line that is long enough is encountered.
More information on handling the arrow keys is in "Other Action Keys" later in this chapter. Modified arrow keys--for example, Alt-arrow--are discussed in "Implementing Modifier Key--Arrow Key Combinations" later in this chapter."

Implementing Selection

"Selecting Objects With the Mouse" earlier in this chapter described how your users can select the objects supplied with the App Kit. There are two situations in which you need to implement selection yourself: when your application has areas of editable text and when you include custom objects and allow your users to make multiple selections of them. This section describes the proper interface behaviors for these situations.

Note - Even if your application uses the supplied Text object for its editable text areas, you still need to implement the modifier-arrow key combinations described in "Implementing Modifier Key--Arrow Key Combinations" later in this chapter.

When implementing selection, make sure that your application never moves the selection out of the user's view. When necessary, the display must scroll itself to make the new selection visible. Users, of course, can choose to move a selection out of view with a scroller. But as soon as the user makes a new selection or extends the initial selection (by such actions as pressing an Arrow key), the application selection should scroll the selection back into view.

Note - To hide the pointer temporarily, use the single-operator function PSobscurecursor().

When Discontinuous Selection Is Not Implemented

Sometimes an application implements selection in an area without implementing discontinuous selection. In situations like this, the Shift key should act just like the Alt key during a selection, and both keys should result in continuous selections.
For example, discontinuous selection is not implemented in the App Kit text object, so both Shift-clicking and Alt-clicking extend the selection continuously. This saves the user from making errors due to pressing the wrong key when trying to extend the selection.

Selection in Text and Selection in Graphics

Dragging a rectangle to make a selection has slightly different results in text and graphics. In text (and other serially arranged material) the selection includes the entire series of characters between the anchor and end points. In graphics (and other material consisting of objects that can be independently arranged, such as icons or the graphic elements that make up a picture) the selection generally includes everything that is even partially within the rectangle defined by the anchor and endpoints. Figure 3-3 shows the difference between selections in text and graphics.

Graphic

Figure 3-3

Managing the Pointer

The pointer is generally handled by the App Kit. There are, however, situations in which an application needs to explicitly hide the pointer or change its shape.

Changing the Pointer

Internal bitmap(12x18)

Your applications can change the pointer from the standard arrow to any
other image of equal size (16 pixels by 16 pixels). When doing so, you must specify what part of the pointer acts like the tip of the arrow. That point, the pointer's hot spot, should be apparent to your users from the image itself. For example, if the pointer is an X, the hot spot should be where the two lines cross.
A shape other than an arrow is more useful in many situations. A typical example is the I-beam pointer used to select the insertion point in text areas. This pointer has its hot spot in the center of the beam.
It is often a good idea to change the shape of the pointer to indicate that the user has entered a mode. In applications that use the modal tool paradigm, the pointer should change to indicate which tool has been selected. For example, the pointer might look like a pencil while thin lines are being drawn in a graphics application, or like a wide brush when painting in broad strokes.
If mouse actions are valid only in a certain area, the pointer should revert to its normal shape when it leaves that area. It is best not to change the pointer too often, however. To avoid confusing your users, use the standard arrow wherever possible.

Hiding the Pointer

A visible pointer is essential for mouse actions, but it can get in the way when users are concentrating on using the keyboard. The text object automatically hides the pointer (makes it disappear from the screen) when users begin to type. The pointer returns to the screen as soon as the user moves the mouse, which signals a shift in attention away from the keyboard and back to the mouse.
The pointer should also be hidden whenever the user selects an insertion point or a range of text. The new selection is a good indication that the user is ready to begin typing, and hiding the pointer prevents confusion between the I-beam pointer and the vertical bar representing the insertion point. Unless it is hidden, the I-beam can obscure the vertical bar. In this case too, the pointer must reappear as soon as the user moves the mouse. (This is not currently implemented by the text object, so each application should do this for itself.)

Mouse Actions for Custom Objects

This section describes the behaviors you should implement for custom controls, application-specific document areas, and other custom objects. It describes how these objects should respond to clicking, dragging, and other mouse operations. You do not need the guidelines in this section if you are only using the standard Application Kit objects.

Reacting to Clicks

When one of your users clicks on an object on screen, the object should provide immediate, visible feedback as soon as the mouse button goes down. Depending on the action paradigm in effect, however, the correct behavior for the object may be to wait until the mouse button is released before it does anything more:
  • If the purpose of the click is direct manipulation of the object, the object should react when the mouse button goes down. For example, when a window is clicked on, it comes to the front of the screen without waiting for the mouse button to go up. Similarly, when editing text, the user is committed to a new selection as soon as the mouse button is pressed.
  • If the click is intended to initiate a targeted action or choose a modal tool, then, in general, the object should act when the mouse button goes up. This gives the user a chance to change his or her mind. If the user moves the pointer off the object before releasing the button, the action is canceled. Suppose, for example, that the user presses the mouse button while the pointer is over the Cut command in the Edit menu. The command is highlighted, but the current selection is not actually cut until the user releases the mouse button. If the user moves the pointer away from the menu before releasing the mouse button, the command will not be carried out.

Note - You can implement multiple-clicks so that they act when the mouse button is pressed the second (or third) time, instead of waiting for the mouse button to go back up (as is usual for a single click). This implementation can help improve the perceived speed of your application.

First Click on a Window

Sometimes the intention of a click is simply to bring a window forward. Your application needs to decide whether the user wanted the click to bring the window forward, or to bring it forward and do some work in the window. Use the following guidelines:
  • If the user chooses a particular control--clicking on a button or a scroller, for example--the click should not only bring the window forward, but should also operate the control. Since controls are small, it is reasonable to assume that the user chose to position the pointer over the control and click on it.
  • If the click is generally within the content area of the window, but not over a control, the click should just bring the window forward, without otherwise acting on it. In particular, it should not alter the current selection.
If the user chooses to double-click in the content area of the window, the normal double-click action should be performed. Double-clicking on a word should select the word whether the window is in front or not.

When Dragging Should Not Imply Clicking

In general, the main action performed by an object should be initiated by a single click, and dragging should be recognized as a click and initiate the same action. But there are situations in which you don't want dragging an object to initiate its action.
For example, the main action associated with a docked application icon is activating an application, but users can also move icons by dragging them. Users should be able to move icons without activating their applications, so dragging and activating must be separate actions.
There are three ways to handle a situation like this:
  • Require users to hold down a modifier key when the object is dragged.
  • Implement the object so that dragging does not perform a click.
  • Implement the object so a click does nothing, and a double-click is required to perform the object's action.
In the case of the docked icon, the first solution (requiring a modifier key to drag the icon) is not appropriate. Moving an icon is a common operation, and unmodified dragging is the natural way to do it.
The second solution (a single-click activates the application and dragging does not perform a click) is not appropriate either, mainly because users who intended to drag the icon could easily click on it accidentally. An accidental click would begin the icon's main action (activating an application), which takes time, brings up windows, and cannot be reversed until the application is fully started. In addition to this, if a single-click started the application, it would be inconsistent with the way application icons behave in the File Viewer. In the File Viewer, a single-click selects the application's file. It is not started up until the user double-clicks it.
So the only acceptable implementation for docked application icons is the third possibility, in which a single-click does nothing and a double-click starts the application.
Another example, in which the second solution (dragging does not imply a single click) was implemented, is the File Viewer's shelf. When the user clicks on the icon of a folder on the shelf, the File Viewer changes to show the folder's path. However, when the user drags the icon off the shelf, the File Viewer does not perform the click's action--it does not change the current path. One of the reasons this solution works is that the shelf differentiates clicking from dragging by having a threshold for dragging. Until the user drags the icon a certain distance, it does not move. Once the user has committed to dragging the icon, it cannot be clicked. The icon also looks very different when it is clicked on (it is highlighted) then when it is dragged (it moves, and a dimmed copy is visible in its old location).
In general, for this kind of implementation, where dragging does not perform a click, the following conditions must be met to be successful:
  • The user gets clear visual feedback that indicates whether the object is reacting to a click or to dragging, and it is difficult for the user to do the wrong thing. For example, if the user starts to drag the object but then decides to put it back, the action should not be treated as a click.
  • The single-click's action matches similar uses of single-clicks elsewhere in the interface.
  • The action initiated by the click does not have consequences that the user might want to avoid and that cannot easily be stopped or reversed. This condition is important because the user might accidentally click on an object when intending to drag it.

When to Use Multiple-Clicking

You should only implement double-clicking for a custom object when it logically extends the action of a single-click. Triple-clicking should only be implemented when there is an action that logically extends a double-click. There are two reasons for this rule, one philosophical and the other programmatic:
  • Complex mouse actions are best remembered and understood when they appear to grow naturally out of simpler actions.
  • Every double-click includes a single-click (the first click in the sequence), and every triple-click includes a double-click. At the time an application receives one click, it cannot know whether additional clicks will be received. So it must first act on the single click, then the double-click, then the triple-click.
For example, the first click of a double-click on a File Viewer icon selects the icon, just as a single-click would. The second click activates the application associated with the icon. A single click in text selects an insertion point, a double-click extends the selection to a word, and a triple-click extends it further to a full line, sentence, or paragraph.
Quadruple-clicks (and above) become increasingly difficult for users to produce or understand. They are neither used nor recommended in the OpenStep user interface. Even triple-clicks should be used sparingly.

Dragging From a Multiple-Click

The act of pressing a mouse button to initiate dragging can be part (the last part) of a double-click or triple-click. If the user does not immediately release the mouse button and begins dragging at the end of a multiple-click, the dragging action can be assigned a meaning that is related to the meaning of the multiple-click.
In text, for example, double-clicking selects a word and dragging from a double-click selects additional words within a range of text. If triple-clicking selects a line, dragging from a triple-click will select additional lines within the range.

How to Use Dragging

Dragging can be implemented in a variety of situations. The three most common are:
  • Moving objects, such as windows and the knobs of scrollers
  • Defining ranges, usually to select the objects within the range
  • Sliding from one object to another in order to extend an action initiated in the first object to the second object
The following sections cover these situations in detail.

Moving Objects

The user can drag a movable object by positioning the pointer over it, pressing the mouse button, and moving the mouse while the button is down. The object should move in such a way that it remains aligned with the pointer on screen. When the object is constrained within an area or a track as a scroller knob is, it should remain as closely aligned with the pointer as possible.
The Application Kit contains support for moving objects between and within applications. It even changes the pointer to indicate whether the object is being moved, copied, or linked. See "Managing the Pointer" earlier in this chapter for more information on changing the pointer.

Defining Ranges

The user can also drag over an area or through a series of items such as text characters to define a range. The position of the pointer when the mouse button is pressed is the anchor point. Its position when the mouse button is released is the endpoint. The difference between the anchor point and endpoint determines the area or objects inside the range. Figure 3-4 shows anchor point and endpoint locations.
Dragging to define a range is mostly used to make a selection (such as a string of text characters or a group of icons) for the targeted-action paradigm.
When the user drags to define a rectangular range, as in a drawing program, applications often drag out, or "rubberband," a rectangle that shows the area between the anchor point and endpoint. See "Selection in Text and Selection in Graphics" earlier in this chapter for more information on the dragging operations that define a rectangular range.

Graphic

Figure 3-4

Sliding From Object to Object

Sometimes a group of closely related objects reacts to dragging as though the user clicked on one of the objects. No matter which object in the group was under the pointer when the mouse button was pressed, the object chosen is the one that is under the pointer when the mouse button is released. (Notice that when an object is not in a group, it is chosen only when it is underneath the pointer both when the mouse button is pressed and when it is released.)
When working with menus users can press the mouse button when the pointer is over one command and release it when it is over another, which chooses the command that is under the pointer when the button is released. Similarly, when working with a tool palette, users can drag the pointer from one tool to another, or when working with a set of radio buttons they can drag the pointer from button to button.
The grouped objects do not have to be all of the same type. For example, a user can drag from a button that controls a pop-up list through the list to make a selection, or from a menu command that opens a submenu into the submenu.
If the user can drag from one object to another in a group of objects, then this fact should be apparent from the way the objects are displayed. Usually, such objects are displayed in a single row or column, as close to each other as
possible. For example, graphical radio buttons should be displayed next to each other, to distinguish them from ordinary buttons. (Graphical radio buttons are discussed in detail in Chapter 7, "Controls.")

When to Use Pressing

For the most part, pressing is an alternative to repeated clicking. It should be used wherever a control's action can be repeated with incremental effect. Clicking a scroll button is a common example. One click scrolls one line of text, a second click scrolls another line, and so on. Pressing the scroll button scrolls continuously, until the mouse button is released.
Pressing is also used to begin the mouse action of sliding from one object to another. If a button controls a pop-up list, the user presses the button and drags through the list to choose one of its options. After pressing a menu command to bring up a submenu, the user can drag into the submenu.

Using Modifier Keys With the Mouse

You can use modifier keys to change the results of mouse operations. Modified mouse actions should be implemented for optional or advanced features of your user interface, because they are harder to remember and require more coordination to produce. They typically extend or alter the effect of the standard mouse action. For example:

Internal bitmap(12x12)

  • Dragging a file icon from one directory window to another moves or copies the file to the new directory, depending on whether the directories are on the same disk or a different disk. Command-dragging always moves the file. Alt-dragging always copies the file. Control-dragging is similar to copying, but the new "copy" of the file is simply a link to the old copy. The user knows what will happen because of the visual feedback the application provides. It changes the pointer shape (to a

    dragging).

    , for example, when Alt-

  • Clicking on a scroll button scrolls a line of text. Alt-clicking scrolls a larger amount of text.
  • Alt-clicking on a window moves it to the front without making it the key window or activating its application.
  • Clicking selects a new insertion point in text. Alt-clicking extends the selection to include everything between the current insertion point and the point of the click. If an application implements discontinuous selection, Shift-clicking will select a new insertion point without dropping the old selection. If discontinuous selection is not implemented, Shift-clicking acts like Alt-clicking.
  • Clicking selects an icon in a directory window. Shift-clicking adds new icons to the current selection. (Shift-clicking of a selected icon removes it from the selection.)

Note - The Caps Lock key does not work for Shift-clicking or Shift-dragging--the Shift key must be held down manually. This way, users will not find themselves Shift-clicking by mistake when they intend only to click.

The Control key (with no other modifier keys) is often used for mouse actions that create or act on links. If your application's documents can receive linked information, then you need to implement the Control-double-click accelerator, as described in the discussion of the Link Inspector panel in Chapter 5, "Panels."
Some modifier keys should be used only in limited circumstances:
  • The Help key should be used only for Help-clicking, which brings up help on the clicked object.
  • The combination of Alt and Control should be used only as a substitute for the Help key. (This is necessary because some keyboards do not have a Help key.)
Applications should avoid distinguishing between the left and right key of the Shift and Alt pairs. Users do not expect such a distinction except for certain computerwide, potentially destructive operations, such as resetting the computer's processor. Also, there is no hardware-independent way to differentiate the left and right modifier keys.

Keyboard Actions

In theory, the keyboard is used only to enter text, and the mouse is used for all other operations, such as making selections and using controls. In reality, a number of actions are initiated from the keyboard. A few, such as Return and Enter, are traditional keyboard actions. Others are keyboard alternatives that
provide convenient shortcuts for initiating mouse actions. There are some special key combinations that modify mouse actions. Figure 3-5 shows a typical Sun keyboard layout.

Graphic

Figure 3-5

A computer keyboard includes standard typewriter keys, which are used to enter letters, numbers, and common symbols. This characteristic is covered in Using the OpenStep Desktop.
The computer keyboard also has keys that are not found on typewriters, including Alt, Control, Command, Help, Enter, and the Arrow keys. These keys, along with the Shift key, are used in keyboard actions and must be considered when developing an application.

Modifier Keys

Shift, Alt, Control, Command, and Help are known as modifier keys because they can modify the results of a mouse operation or another key on the keyboard. If a user presses Shift-3, for example, it yields the # character, and pressing Command-c issues a Copy command. Pressing a modifier key by itself does nothing.
To use a modifier key, the user must hold it down and press the key (or perform the mouse action) to be modified. More than one modifier key can be used at a time. (Command-Shift-c is a valid combination.)
Use of modifier keys is summarized the following paragraphs.
  • The Shift key modifies keystrokes to produce the uppercase character on alphabetic keys and the upper character on numbers and other two-character keys. It is sometimes used with other modifier keys.
  • The Alt key modifies keystrokes to produce an alternate character to the one that appears on the key. In general, the characters produced are special characters that are used relatively infrequently. To find out which alternate characters are generated by which keys, see Using the OpenStep Desktop.

Note - On SPARC keyboards, this function is mapped to the Alt key. On x86 keyboards, it is mapped to the right Alt key.

  • The Control key modifies keystrokes to produce standard ASCII control characters. Some control characters are generated by single character keys--for example, Tab is Control-i, Return is Control-m, and backspace (Shift-Delete) is the same as Control-h.

Note - On SPARC keyboards, this function is mapped to the Control key. On x86 keyboards it is mapped to the Ctrl key.

  • The Command key provides a way to choose menu commands with the keyboard rather than the mouse. As an alternative to clicking on a menu command with the mouse, the user can press the Command key in conjunction with the character displayed in the menu next to that command. For example, Command-c chooses the Copy command.

Note - On SPARC keyboards, this function is mapped to the Meta (·) keys. On x86 keyboards, it is mapped to the left Alt key.

  • The Help key does not modify keystrokes. It is used only to modify mouse actions, as described in "Using Modifier Keys with the Mouse" earlier in this chapter.

Note - On SPARC keyboards, this function is mapped to the Help and F1 keys. On x86 keyboards, it is mapped to the F1 key.

Special Command-Key Combinations

Several Command-key combinations produce special effects. Some play a particular role in the user interface. Others, in effect, give commands to the computer itself rather than to just one application. They cannot be used for functions other than those listed below.
  • Command-. (period) should let users cancel the current operation in the active application. (The Esc key also performs does this.) Although the Application Kit has code to support Command-., it is not automatic. An application must ask for this functionality.
  • Command-space should be used for file name completion. In contexts where it is appropriate for the user to type a file name (such as in an Open panel), Command-space bar displays as many characters as match all possible file names in the directory. If the user first types enough characters to identify a particular file and then presses the space bar with the Command key down, the remaining characters of the file name are filled in. (In many applications, the Esc key also performs file name completion.)

Other Action Keys

This section describes the kinds of results that you can appropriately implement for the non text keys that initiate actions. These keys generate non display characters that tell the application to initiate some action. The action will depend on how the application handles the special character. Some typical responses to these special character keys are listed here.
  • The Return key moves the insertion point or prompt to the beginning of the next line, much like the carriage return key of a typewriter. When data is entered in a text field or form, Return moves the insertion point and informs the application that the data is ready for processing.
  • The Enter key, like Return, signals that data is ready for processing. It need not move an insertion point or prompt to the beginning of the next line. Enter can also be generated with Command-Return.
  • The Backspace key, usually located above the Return key, as shown in Figure 3-5, removes the preceding character in text or deletes the current selection. Shift-Backspace generates the backspace character, which moves the insertion point back one character. In most applications, the Del key has the same function as the backspace key.
  • The Tab key moves forward to the next tab stop, or to the next text field in a sequence. Shift-Tab moves backward to the previous tab stop or text field.
  • The Arrow keys move the symbol that is used in some contexts to track where the user is writing or entering data--for example, the insertion point in a document processor. The arrow keys' action is described in "How the Arrow Keys Affect a Text Selection" later in this chapter, and "Implementing Modifier--Arrow Key Combinations" earlier in this chapter.

Handling Arrow Characters

Because the Arrow keys generate the same character codes as the Symbol font's arrow characters, text objects should check to see which key generated the character. The Arrow keys never produce visible arrow characters. However, when a non arrow key (perhaps modified by the Alternate key) produces an arrow character code, it should produce visible arrow characters, and not result in Arrow key functionality.
For example, Alt-f should produce a visible left-arrow symbol, as shown in the User's Guide, instead of moving the insertion point left one character.

Implementing Keyboard Alternatives

Many users find it faster and easier to operate graphical objects with their keyboards than with the mouse. The standard menus include keyboard alternatives for some operations; you should consider providing keyboard alternatives for the operations that will be most frequently performed in your applications.

Note - For most applications, keyboard input is handled automatically. Text entry and display are handled by the App Kit's Text object, and keyboard alternatives are automatically converted into clicks on the controls they are associated with. All you have to do is choose keyboard alternatives (as discussed later in this chapter) and then specify them in Interface Builder(TM). If your application does not use the Text object for its text entry you will need to write code that handles keyboard input.

Keyboard alternatives consist of a single alphanumeric keystroke, which is modified by the Command key (and possibly another modifier key). They are most often used for menu commands, although they are permitted for a panel's buttons and pull-down lists, as well.
Although a keyboard alternative is associated with a graphic object, the object does not have to be on the screen for the alternative to function. Keyboard alternatives for menu commands and panel buttons will work when the menu or panel is hidden.
This section contains guidelines for assigning keyboard alternatives to application functions. There are three sets of keyboard alternatives--reserved, required, and recommended. Each set is listed in its own table.
Notice that users can use the Preferences application to change the keyboard alternatives (for every application), which means the keyboard alternatives you set up are only the initial settings.

Reserved Keyboard Alternatives

If your application provides a function listed in Table 3-1, you must use the command and reserved keyboard alternative assigned to it. For example, if your application opens files it must have the Open command, and the function Command-o must be the keyboard alternative.
You cannot use these reserved characters as alternatives for any other commands. If your application does not allow the user to open files, it will not have an Open command and must not use Command-o as a keyboard alternative. (See "Standard Menus and Commands" in Chapter 6 for more information on the listed commands and menus.)
Table 3-1
Keyboard AlternativeCommandMenu
Command-?HelpInfo menu
Command-aSelect AllEdit menu
Command-cCopyEdit menu
Command-hHideMain menu
Command-nNewDocument menu
Command-oOpenDocument menu
Table 3-1 (Continued)
Keyboard AlternativeCommandMenu
Command-pPrintMain menu
Command-qQuitMain menu
Command-sSaveDocument menu
Command-vPasteEdit menu
Command-wClose WindowWindows menu
Command-xCutEdit menu
Command-zUndoEdit menu

Required Keyboard Alternatives

If your application provides a function listed in Table 3-2, you must use the command and required keyboard alternative assigned to it. For example, if the application has a Find panel, you must use Command-f as the keyboard alternative for bringing it up. See "Standard Menus and Commands" in Chapter 6 for more information on the listed commands and menus.
If the application does not implement a listed function (it does not have a Find panel), you can assign its required keyboard alternative (Command-f) to another menu command. However, to preserve interapplication consistency, it is strongly recommended that you first try to use characters other than those on this list.
Table 3-2
Keyboard AlternativeCommandMenu
Command-;Check SpellingEdit menu
Command-bBold (Unbold)Font menu
Command-dFind PreviousFind menu
Command-eEnter SelectionFind menu
Command-fFind PanelFind menu
Command-gFind NextFind menu
Table 3-2 (Continued)
Keyboard AlternativeCommandMenu
Command-iItalic (Unitalic)Font menu
Command-tFont PanelFont menu
Command-CColorsVaries

Recommended Keyboard Alternatives

If your application provides a function listed in Table 3-3 and you want to set up a keyboard alternative for it, you must use the recommended keyboard alternative. For example, if you provide a keyboard alternative for the Copy Ruler command you must use Command-1.
If you don't use the keyboard alternative for the recommended function, you can use it for another command. For example, if you don't set up an alternative for the Copy Ruler command, Command-1 can be used as a keyboard alternative for another command.
Table 3-3
Keyboard AlternativeCommandMenu
Command-1Copy RulerText menu
Command-2Paste RulerText menu
Command-3Copy FontFont menu
Command-4Paste FontFont menu
Command-jJump to SelectionFind menu
Command-mMiniaturize WindowWindows menu
Command-rShow RulerText menu
Command-PPage LayoutFormat menu
Command-SSave AsDocument menu
Command-VPaste and LinkLink

Application-Specific Keyboard Alternatives

Because the OpenStep user interface is visual, every operation--every menu command, every scrolling operation, and so on--has a graphical representation that can be operated with the mouse. Keyboard alternatives are just that: alternatives. You should never set up an alternative for an operation that cannot be performed with the mouse.
Keyboard alternatives are allowed only for the commands in a menu, the buttons in a panel, or the items in a pull-down list. The characters used as keyboard alternatives must be visible to your users in the menu, panel, or list. Menus display them on the commands, and pull-down lists follow this example. A panel can identify the keyboard alternatives for its buttons in any way appropriate to the design of the panel.
When you decide which operations will have keyboard alternatives, your main consideration should be frequency of use. It is better to assign a keyboard alternative to a frequently used command than to one that is used less often. Infrequently used commands--such as the Info Panel command--should never have keyboard alternatives.
You should also try to assign keyboard alternatives to commands that are needed while users are working with the keyboard (for example, the commands in the Find menu). Keyboard alternatives for these commands let users keep working without moving from the keyboard to the mouse and back again.
You can also use keyboard alternatives that enable proficient users to work with one hand on the keyboard and the other on the mouse. For example, Command-x, Command-c, and Command-v allow users to select with the mouse while carrying out cut, copy, and paste operations from the keyboard. These keyboard alternatives free users from having to move the pointer out of the region where they are working just to click on a command.
If a keyboard alternative is assigned to one command from a set of parallel commands that control formatting or viewing data (a set of commands that lets users sort items in various ways, for example), the command that restores the default setting should have a keyboard alternative, too. Keyboard actions can then take the user to an alternate format and back to the default, rather than just half way.

Note - You do not need to assign a keyboard alternative to every command. Remember that users can create their own global keyboard alternatives with the Preferences application.

Choosing the Character

Any character except the period (.) and the space can be used for a keyboard alternative, but some characters have been set aside for the reserved, required, and recommended keyboard alternatives. If the character is a letter, it can be either uppercase or lowercase, although lowercase characters are preferred because they do not require the user to press two modifier keys (Command and Shift) at once.
When choosing the character for a keyboard alternative, try to make it mnemonic. If possible, it should be the first letter of the command it performs. If it is closely related to a command that already has a keyboard alternative, then you might want to choose a character physically near the existing one.
For example, the Find command's keyboard alternative is Command-f, taken from the first letter of the command. Two commands related to Find have keyboard alternatives that use the keys next to "f." The Find Next command uses Command-g, because it is just to the right of "f" and Find Previous command uses Command-d, because it is just to the left of "f."

Using the Alternate Key

If necessary, your application can have keyboard alternatives that use the Command and Alt key together to operate them. This is not desirable; you should exhaust all reasonable possibilities using the Command key or Command-Shift before you use Alt. See Figure 3-6.
If you do set up a keyboard alternative that requires the Alt key, the alternative character should be displayed in italics.

Graphic

Notice that the italicized character identifies the key that the user presses while holding down Command and Alt, rather than the character that would be typed if the user held down Alt.

Note - Keyboard alternatives operated with the Alt key are difficult to recognize, and the significance of italic characters in menus is not explained in the OpenStep user documentation. If you implement any keyboard alternatives operated by the Alt key, make sure that the documentation for your application explains the meaning of the italicized character.

When Mouse Operations and Keyboard Alternatives Differ

A keyboard alternative should generally do exactly what the corresponding mouse action does. There are, however, a few cases in which it is acceptable to have the keyboard alternative do just a bit more than the mouse operation. These cases are rare and they often go unnoticed by users because the differences are both subtle and intuitive.
For example, the Edit application has a Find panel which is brought up with the Find Panel menu command or its Command-f keyboard alternative. When opened from the menu, the panel usually remains open until the user explicitly closes it, since it may be used for several Find operations before it is closed. But a user whose attention is focused on typing often wants to find a word in a document and then resume typing without returning to the Find panel.
Edit handles this by implementing a slightly different behavior when the panel is opened with the keyboard alternative. If a user opens the panel with the keyboard and initiates the search by pressing Return, Edit assumes that this user wants to continue typing as soon as the word is found, and it closes the panel when the Find operation is complete. The user does not need to switch to the mouse and activate the document window.
A keyboard alternative that has been handled like this simply does what the user expects and accomplishes either or both of the following:
  • Reduces the number of clicks or keystrokes the user needs to perform
  • Eliminates the need to switch from the keyboard to the mouse and back again
In general, you should start with keyboard alternatives that result in the same behavior as their associated mouse actions. In those rare cases when the keyboard alternative should differ from the mouse action, the need becomes apparent in everyday use.

Implementing Modifier Key-Arrow Key Combinations

If your application allows text selection, you are encouraged to implement the characteristics described in this section for modifier key-Arrow key combinations. These combinations retain the basic directional orientation of each arrow key but alter the behavior of the key somewhat. Before reading this section, you should understand the standard arrow key behavior, which is described in "How the Arrow Keys Affect a Text Selection," earlier in this chapter.

Control-Arrow Combinations

An arrow key modified by the Control key should move the insertion point to the edge of the current display. The left arrow key moves the insertion point in front of the first visible character on the line where the current selection begins, and the right arrow key puts it after the last visible character on the line where the current selection ends.
The up arrow key moves the insertion point to the first visible line of the display, directly above the beginning of the current selection. The down arrow key moves the insertion point to the last visible line, directly below the end of the current selection.
When the insertion point is already at one edge of the currently visible display, the Control-Arrow combination that would normally move it to that edge will scroll the display (by the amount of a page scroll) and move the insertion point to the edge of the new display. When the insertion point reaches the beginning of a line, the left Arrow key does not move it further (for example, to another line). The right Arrow key does not move it beyond the end of a line.

Shift-Arrow Combinations

An Arrow key modified by the Shift key should move the insertion point from word to word. Shift-left arrow moves it to the left of the current selection to the beginning of a word. Shift-right Arrow moves it to the right of the current selection to the end of a word.
Shift-up Arrow moves the insertion point to the beginning of the word one line directly above the beginning of the current selection. Shift-down Arrow moves it to the end of the word one line directly below the end of the current selection. As the up and down Arrow keys move the insertion point from line to line, they choose words that lie directly above or below the original starting point. (In other words, the location of the insertion point can be calculated by the same rules that determine the edge of the selection when the user double-clicks and drags directly upward or directly downward.)

Alt-Arrow Combinations

An Arrow key modified by the Alt key should extend the current selection by one character or one line at a time. The edge moved first becomes the active edge; any subsequent motion with an Arrow key will move the active edge--left or right, up or down.
If, for example, the user presses Alt-left Arrow first, it moves the beginning of the current selection (its left edge) one character to the left (toward the beginning of the document). After this, the left and right Arrow keys will both move the left edge, either one character to the left or one character to the right. If the user presses Alt-right Arrow first, the end of the current selection (the right edge) moves one character to the right (toward the end of the document) and becomes the active edge, after which both keys move the right edge.
Alt-up arrow and Alt-down Arrow are similar. If the user presses Alt-up Arrow first, the top edge of the selection moves up one line and becomes the active edge. If the user presses Alt-down Arrow first, it moves the edge of the current selection down one line, after which both keys move the edge of the selection.

Other Arrow Key Combinations

More than one modifier key can be used in combination with an arrow key, with additive results. Thus, Shift-Alt-right Arrow extends the selection to the end of a word, and Control-Shift-up Arrow places the insertion point at the beginning of a word in the first visible line of the display. Remember that Alt and Control cannot be used together because that combination is reserved by the system as an alternative for the Help key.