GDK Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
Input Methods provide a way for complex character sets to be used in GTK+. Languages such as Chinese, Japanese, and Korean (often abbreviated to CJK) use a large number of ideographs, making it impossible to support all characters with a simple keyboard. Instead, text is usually pre-edited using a phonetic alphabet and then composed to form the ideographs.
GTK+ makes use of the input method mechanism provided by the X Windows platform. When a GTK+ application is started, it opens a connection to the input method appropriate for the current locale (if any).
Widgets which handle textual input, such as GtkEntry, need to do a number of things to support internationalized text input:
Check if an input method is being used with gdk_im_ready(). If it is, create a new Input Context using gdk_ic_new(). Find out which events the Input Context needs to receive with gdk_ic_get_events(), and make sure that the widget's window receives these events using gdk_window_set_events().
Update the appropriate Input Context attributes using gdk_ic_set_attr().
Call gdk_im_begin() or gdk_im_end() to start or finish editing the text.
The string and length fields of the GdkEventKey struct should be used to insert the composed text into the widget.
Destroy the Input Context.
See the XLib reference manual for more detailed information on input methods, and the GtkEntry and GtkText widgets for some example code.
Used for each widget that handles internationalized text input using the global input method.