• Aucun résultat trouvé

VIRTUAL KEYBOARDS

Dans le document 0 0 0 (Page 117-122)

CHAPTER 6 KEYBOARD INPUT

6.1 VIRTUAL KEYBOARDS

A virtual keyboard is a LISP object that you create with the CREATE-KB function. It forms the link between the physical keyboard and your program. Although there is only one physical keyboard per workstation, you can have any number of virtual keyboards.

6-1

6.1.1 Using Virtual Keyboards: An Overview

The first step in using a virtual keyboard is creating it.

CREATE-KB function creates and returns a virtual keyboard:

Theo {SETF *KB* {CREATE-KB))

The next step is to associate the keyboard with a viewport. The ENABLE-VIEWPORT-KB function does this:

{ENABLE-VIEWPORT-KB *KB* *INPUT-WINDOW*)

When you associate a virtual keyboard with a viewport, a KB icon appears in the right corner of the viewport's-banner:

Th_i_s icon ind_icates to the user that the _ physical keyboard .can_ .be attached to this viewport. From the software point of view, the viewport is added to an assignment list of viewports that can have the physical keyboard attached to them. The CYCLE key (function key FS) attaches the physical keyboard to each viewport on the assignment list in turn.

0

When the physical keyboard is attached to the viewport, the KB icon i s Q highlighted:

This indicates that keystrokes will now be directed through virtual keyboard associated with this viewport.

NOTE

If a call to CREATE-WINDOW includes :NOKB-ICON T, the associated viewport will be unable to acquire a KB icon. It can still, however, have a virtual keyboard associated with it.

Figure 6-1 illustrates the sequence of events just described.

the

0

0

0

(SETF *KB* (CREATE-KEYBOARD)) (ENABLE-VIEWPORT-KB

*KB* *INPUT-WINDOW*)

(ENABLE-KB *KB*)

ML0·216-B6

Figure 6-1: Creating and Attaching Virtual Keyboards

A virtual keyboard associated with a viewport to

• Keyboard characteristics of the virtual keyboard (established with the SET-KB-ATTRIBUTES function) are imposed on the

(ENABLE-VIEWPORT-KB *KB* *WINDOW-2*) 6-3

Now both *INPUT-WINDOW* and *WINDOW-2* are associated with the

keyboard *KB*. Whenever *KB* becomes the active keyboard, through any

Q

means, the KB icon in both viewports will be highlighted. Both viewports have entries on the assignment list; that is, the CYCLE key.

will assign the physical keyboard to first one, then the other.

However, whenever the physical keyboard is assigned to either, the KB icons in both will be highlighted.

It is important to note that the association of a virtual keyboard with a viewport makes no provision for the echoing of characters typed through that virtual keyboard, or for a cursor in the viewport. It is the responsibility of your program to take the appropriate response to input. Unless you set up an interrupt function to receive the keystrokes, they will be lost. Section 6.2 contains more information about this.

6.1.2 Creating and Deleting Virtual Keyboards

The CREATE-KB function creates and returns a virtual keyboard object.

The keyboard returned by CREATE-KB is not associated with any viewport when it is created; you must do that later.

0

The DELETE-KB function deletes a virtual keyboard object. Since

virtual keyboard objects consume system resources, you should take

Q

care to delete them when you no longer need them.

If you delete a keyboard that is currently associated with a viewport or with the physical keyboard, those associations are terminated.

6.1.3 Associating Keyboards with Viewports and the Physical Keyboard

Before you can receive any input from a virtual keyboard, you must

Q

associate it with a viewport. Two functions do this:

• The ENABLE-VIEWPORT-KB function associates the keyboard named in its first argument with the viewport corresponding to the window named in its second argument.

• The ENABLE-KB function's primary purpose is to make a keyboard the active keyboard. However, it takes an optional window argument which, if supplied, associates the keyboard with the corresponding viewport.

Associating a keyboard with a viewport causes any keyboards that were previously associated with that viewport to become dissociated. You can also use the DISABLE-VIEWPORT-KB function to explicitly dissociate.

a viewport and keyboard.

Q

0

0

0

0

0

KEYBOARD INPUT

Once associated (associated with program control:

with. a viewport, a keyboard can become active the physical keyboard) through user action or under

• The user can make a keyboard active either by pressing the CYCLE key repeatedly, or hy moving the pointer cursor into a viewport and pressing the left pointer button. (The second method does not work if the default button action has been superseded for that window; see Chapter 5.)

• The program can use the ENABLE-KB function to make a specific keyboard active.

Either the user or the program can make a virtual keyboard inactive.

The user can press the CYCLE key or use the pointer to make another keyboard active; or the program can use the DISABLE-KB function.

Three functions let you find out if a virtual keyboard is active, respond to a keyboard's becoming active and inactive:

and

• The TEST-KB function returns T if the keyboard named argument is connected to the physical keyboard, otherwise •

in its and NIL

• The SET-GAIN-KB-ACTION and SET-LOSE-KB-ACTION functions specify actions to take when a specified virtual keyboard becomes active and inactive, respectively. The action can be an interrupt function or NIL to specify no action.

6.1.4 Setting Keyboard Attributes

Each virtual keyboard has associated with it a set of keyboard attributes. These attributes are imposed on the physical keyboard when the virtual keyboard becomes active. The attributes are the

following:

• Autorepeat controls whether keys on the keyboard repeatedly generate a character when held down.

• Two keyclick attributes control whether, and how loudly, a click sounds when a key is pressed.

• Seven key group enabling and disabling attributes control whether keys in the following groups can generate keystrokes:

Function keys F6 through F10 Function keys F11 through F14 Function keys F17 through F20 The HELP and DO keys

6-5

The six editing keys below the HELP and DO keys The arrow keys

The numeric keypad keys

You set virtual keyboard attributes with the SET-KB-ATTRIBUTES function. The first argument to SET-KB-ATTRIBUTES is a virtual keyboard; the remaining arguments are keyword-value pairs that identify the attribute and its setting.

The GET-KB-ATTRIBUTE function returns the value attribute, and the GET-KB-ATTRIBUTE-LIST function all the keyboard attributes and their settings for a keyboard.

Dans le document 0 0 0 (Page 117-122)