Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Text /
Appendix C - Keyboard Resources / Key-Caps Resource (Type 'KCAP')


Resource Format

Figure C-10 shows the format for the key-caps resource.

Figure C-10 Format of the key-caps resource

The key-caps resource has these elements:

Each shape entry in the main array has two components:

Each key entry in a shape entry specifies the following information:

Listing C-4 is an abridged example of the data in a key-caps resource, shown in
Rez format.

Listing C-4 Sample key-caps resource data in Rez format

resource 'KCAP' ($01) {
            {60, 45, 220, 455},              /* boundsRect */
            {12, 42, 36, 368},               /* textRect */
            {
               { {21, 21} }, {               /* Shape No. 1 */
                  0, or, $35, 50, 10;           /* escape */
                  0, or, $12, 0, 20;            /* 1 ! */
                  0, or, $13, 0, 20;            /* 2 @ */
                  ...
                  0, or, $7D, 0, 20;            /* Down arrow */
                  0, or, $7E, 0, 20;            /* Up arrow */
                  0, or, $41, 0, 80;            /* Keypad . */
                  0, or, $55, -20, 0;           /* Keypad 3 */
                  ...
            };
               { {21, 31} }, {               /* Shape No. 2 */
                  0, or, $30, 70, 10;           /* Tab */
                  0, or, $33, -20, 260          /* Backspace */
            };
                  ...
               {  {-21, 36}; {-41, 15} }, {  /* Shape No. 3 */
               0, or, $24, 111, 265             /* Return */
            };
            ...
         }
};
The basic square key has a shape array of { {21, 21} }, which puts the origin in the upper-left corner of the key. The first key in the key array for this shape is the Escape key (key code $35) in the upper-left corner of the keyboard; this key is at vertical and horizontal delta offsets of (50, 50) from the upper-left corner of the window's content region. The next key with this shape is immediately to the right, with its origin at delta offsets of (0, 20) from the origin of the previous key.

The next shape is the slightly wider key with a shape array of { {21, 31} }, used for the Tab and Backspace keys. The origin of the Tab key is at offsets (70, 10) from the upper-left corner of the window's content region (which puts the Tab key one row below the Escape key).

The shape array for the Return key is { {-21, 36}; {-41, 15} }, which means that it is the union of two rectangles: the first rectangle is from the origin of the key to the first point, and the second rectangle is from the first point to the second point. (Both points are measured relative to the key origin, however.) This shape array puts the Return key's origin in the lower-left corner of the key. See Figure C-11. The origin is at offsets (111, 265) from the upper-left corner of the window's content region.

Figure C-11 Shape array and resulting region for the Return key


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996