Title Banner

Previous Book Contents Book Index Next

Newton Developer Technical Information: Newton Programmer's Guide: 2.1 OS Addendum /
Chapter 4 - Keyboard Enhancements / Using the Keyboard Enhancements


The Caret Stack and Caret Activation

The system maintains a stack of key-views, which allows the current key-view to be reset to the previous one when a key-view is closed. For example, when the user opens the Find slip while the caret is in the notepad, the caret is moved from the notepad to the input line in the Find slip. Then, when the user closes the find slip, the caret is returned to the notepad in its former location.

The system attempts to preserve selections in this process. If the user selects a word in the notepad, then opens the find slip and closes it, the word in the notepad will be re-selected.

The caret stack mechanism is largely invisible to applications. When a view becomes the key-view (either through a user action or through restoration from the caret stack) or when a view loses the key-view, the following message is sent to the view that is losing the caret:

oldkeyview:ViewCaretActivateScript(nil);

Immediately thereafter, the following message is sent to the view that is getting the caret:

newkeyview:ViewCaretActivateScript(true);

You can use the ViewCaretActivateScript method to trigger actions when your view becomes the key-view or is no longer the key-view. The return value is ignored.

Listing 4-5 shows an example of a ViewCaretActivateScript method. This implementation plays a sound at caret activation time: if a keyboard is connected, it beeps; if not, it clicks.

Listing 4-5 An example of a ViewCaretActivateScript method

ViewCaretActivateScript: func( active )

begin if KeyboardConnected() then :SysBeep(); else PlaySound(ROM_Click); nil; end


Previous Book Contents Book Index Next

© Apple Computer, Inc.
26 APR 1997



Navigation graphic, see text links

Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help