[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
General Programming Concepts: Writing and Debugging Programs

Using Callbacks

Applications that use input methods should provide callback functions so that the Input Method Editior (IMED) can communicate with the user. The type of input method you use determines whether or not callbacks are necessary. For example, the single-byte input method does not need callbacks, but the Japanese input method uses them extensively with the pre-edit facility. Pre-editing allows processing of characters before they are committed to the application.

When you use an input method, only the application can insert or delete pre-edit data and scroll the text. Consequently, the echo of the keystrokes is achieved by the application at the request of the input method logic through callbacks.

When you enter a keystroke, the application calls the IMFilter subroutine. Before returning, the input method can call the echoing callback function for inserting new keystrokes. Once a character has been composed, the IMFilter subroutine returns it, and the key strokes are deleted.

In several cases, the input method logic has to call back the client. Each of these is defined by a callback action. The client specifies what callback should be called for each action.

There are three types of callbacks:

Initializing Callbacks

All callbacks must be identified when you call the IMCreate subroutine. The IMCallback structure contains the address for each callback function. The caller of the IMCreate subroutine must initialize the IMCallback structure with the addresses.

The callback functions can be called before the IMCreate subroutine returns control to the caller. Usually, the IMTextStart callback is called to identify the size of the pre-edit buffer.

Related Information

National Language Support Overview for Programming .

The IMAuxCreate subroutine, IMAuxDestroy subroutine, IMAuxDraw subroutine, IMAuxHide subroutine, IMBeep subroutine, IMIndicatorDraw subroutine, IMIndicatorHIde subroutine, IMTextCursor subroutine, IMTextDraw subroutine, IMTextHide subroutine, IMTextStart subroutine, IMIoctl subroutine.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]