Object Hierarchy:

Object hierarchy for IMContext


[ CCode ( type_id = "gtk_im_context_get_type ()" ) ]
public abstract class IMContext : Object

`GtkIMContext` defines the interface for GTK input methods.

`GtkIMContext` is used by GTK text input widgets like `GtkText` to map from key events to Unicode character strings.

By default, GTK uses a platform-dependent default input method. On Windows, the default implementation is IME-based and on Wayland, it is using the Wayland text protocol. The choice can be overridden programmatically via the [property@Gtk.Settings:gtk-im-module] setting. Users may set the `GTK_IM_MODULE` environment variable to override the default.

Text widgets have a GtkIMContext:im-module property (e.g. [property@Gtk.TextView:im-module]) that may also be used to set input methods for specific widget instances. For instance, a certain entry widget might be expected to contain certain characters which would be easier to input with a specific input method.

An input method may consume multiple key events in sequence before finally outputting the composed result. This is called *preediting*, and an input method may provide feedback about this process by displaying the intermediate composition states as preedit text.

For instance, the built-in GTK input method `GtkIMContextSimple` implements the input of arbitrary Unicode code points by holding down the < kbd>Control</kbd> and <kbd>Shift</kbd> keys and then typing <kbd>U</kbd> followed by the hexadecimal digits of the code point. When releasing the <kbd>Control</kbd> and <kbd>Shift</kbd> keys, preediting ends and the character is inserted as text. For example,

Ctrl+Shift+u 2 0 A C

results in the € sign.

Additional input methods can be made available for use by GTK widgets as loadable modules. An input method module is a small shared library which provides a `GIOExtension` for the extension point named "gtk-im-module".

All known sub-classes:

Namespace: Gtk
Package: gtk4



Creation methods:



Inherited Members: