It derives from <GObject>.
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.
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. To do so, the <GtkIMContext> will emit
imcontext:preedit-start,
imcontext:preedit-changed
and imcontext:preedit-end
signals.
For instance, the built-in GTK input method
<GtkIMContextSimple> implements the input
of arbitrary Unicode code points by holding down the Control and
Shift keys and then typing u followed by the hexadecimal
digits of the code point. When releasing the Control and
Shift 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".
To connect a widget to the users preferred input method, you should use
<GtkIMMulticontext>.
parent-instanceAdditional hints that allow input methods to fine-tune their behaviour.
Its value is a <GtkInputHints> (or, to set it,
a list of its symbols, or one of them).
Set it with (set! (imcontext:input-hints self) value).
The purpose of the text field that the ‘GtkIMContext is connected to.
This property can be used by on-screen keyboards and other input methods to adjust their behaviour.
Its value is a <GtkInputPurpose> (or, to set
it, one of its symbols).
Set it with (set! (imcontext:input-purpose self) value).
Requests the platform to show an on-screen keyboard for user input.
This method will return #t if this request was actually performed
to the platform, other environmental factors may result in an on-screen
keyboard effectively not showing up.
Passed: a <GtkIMContext>.
Passed, or left out: a <GdkEvent>, or #f.
Returned: a boolean.
#t if an on-screen keyboard could be requested to the platform.
Asks the widget that the input context is attached to delete characters
around the cursor position by emitting the ::delete_surrounding
signal.
Note that offset and n-chars are in characters not in bytes
which differs from the usage other places in
<GtkIMContext>.
In order to use this function, you should first call
imcontext:get-surrounding to get
the current context, and call this function immediately afterwards to
make sure that you know what you are deleting. You should also account
for the fact that even if the signal was handled, the input context
might not have deleted all the characters that were requested to be
deleted.
This function is used by an input method that wants to make substitutions in the existing text in response to new input. It is not useful for applications.
Passed: a <GtkIMContext>.
Passed: a 32-bit integer.
offset from cursor position in chars; a negative value means start before the cursor.
Passed: a 32-bit integer.
number of characters to delete.
Returned: a boolean.
#t if the signal was handled.
Allow an input method to forward key press and release events to another
input method without necessarily having a
<GdkEvent> available.
Passed: a <GtkIMContext>.
Passed: a boolean.
whether to forward a key press or release event
Passed: a <GdkSurface>.
the surface the event is for
Passed: a <GdkDevice>.
the device that the event is for
Passed: an unsigned 32-bit integer.
the timestamp for the event
Passed: an unsigned 32-bit integer.
the keycode for the event
Passed: a <GdkModifierType>, or a list of
its symbols, or one of them.
modifier state for the event
Passed: a 32-bit integer.
the active keyboard group for the event
Returned: a boolean.
#t if the input method handled the key event.
Allow an input method to internally handle key press and release events.
If this function returns #t, then no further processing should be
done for this key event.
Passed: a <GtkIMContext>.
Passed: a <GdkEvent>.
the key event
Returned: a boolean.
#t if the input method handled the key event.
Notify the input method that the widget to which this input context corresponds has gained focus.
The input method may, for example, change the displayed feedback to reflect this change.
Passed: a <GtkIMContext>.
Notify the input method that the widget to which this input context corresponds has lost focus.
The input method may, for example, change the displayed feedback or reset the contexts state to reflect this change.
Passed: a <GtkIMContext>.
Retrieve the current preedit string for the input context, and a list of attributes to apply to the string.
This string should be displayed inserted at the insertion point.
Passed: a <GtkIMContext>.
Returned: a string.
location to store the retrieved string. The string retrieved must be
freed with byte-array:free.
Returned: a <PangoAttrList>.
location to store the retrieved attribute list. When you are done with
this list, you must unreference it with attr-list:unref.
Returned: a 32-bit integer.
location to store position of cursor (in characters) within the preedit string.
Retrieves context around the insertion point.
Input methods typically want context in order to constrain input text based on existing text; this is important for languages such as Thai where only some sequences of characters are allowed.
This function is implemented by emitting the imcontext:retrieve-surrounding signal on the
input method; in response to this signal, a widget should provide as
much context as is available, up to an entire paragraph, by calling
imcontext:set-surrounding.
Note that there is no obligation for a widget to respond to the
::retrieve-surrounding signal, so input methods must be prepared
to function without context.
Passed: a <GtkIMContext>.
Returned: a boolean.
TRUE if surrounding text was provided; in this case you must free
the result stored in text.
Returned: a string.
location to store a UTF-8 encoded string of text holding context around
the insertion point. If the function returns #t, then you must
free the result stored in this location with
byte-array:free.
Returned: a 32-bit integer.
location to store byte index of the insertion cursor within text.
Retrieves context around the insertion point.
Input methods typically want context in order to constrain input text based on existing text; this is important for languages such as Thai where only some sequences of characters are allowed.
This function is implemented by emitting the imcontext:retrieve-surrounding signal on the
input method; in response to this signal, a widget should provide as
much context as is available, up to an entire paragraph, by calling
imcontext:set-surrounding-with-selection.
Note that there is no obligation for a widget to respond to the
::retrieve-surrounding signal, so input methods must be prepared
to function without context.
Passed: a <GtkIMContext>.
Returned: a boolean.
TRUE if surrounding text was provided; in this case you must free
the result stored in text.
Returned: a string.
location to store a UTF-8 encoded string of text holding context around
the insertion point. If the function returns #t, then you must
free the result stored in this location with
byte-array:free.
Returned: a 32-bit integer.
location to store byte index of the insertion cursor within text.
Returned: a 32-bit integer.
location to store byte index of the selection bound within text
Notify the input method that a change such as a change in cursor position has been made.
This will typically cause the input method to clear the preedit state.
Passed: a <GtkIMContext>.
Set the client widget for the input context.
This is the <GtkWidget> holding the input focus.
This widget is used in order to correctly position status windows, and
may also be used for purposes internal to the input method.
Passed: a <GtkIMContext>.
Passed, or left out: a <GtkWidget>, or #f.
the client widget. This may be #f to indicate that the previous
client widget no longer exists.
Notify the input method that a change in cursor position has been made.
The location is relative to the client widget.
Passed: a <GtkIMContext>.
Passed: a <GdkRectangle>.
new location
Sets surrounding context around the insertion point and preedit string.
This function is expected to be called in response to the
imcontext:retrieve-surrounding signal, and will
likely have no effect if called at other times.
Passed: a <GtkIMContext>.
Passed: a string.
text surrounding the insertion point, as UTF-8. the preedit string should not be included within text
Passed: a 32-bit integer.
the length of text, or -1 if text is nul-terminated
Passed: a 32-bit integer.
the byte index of the insertion cursor within text.
Sets surrounding context around the insertion point and preedit string.
This function is expected to be called in response to the
"retrieve_surrounding" signal, and will likely have no effect if
called at other times.
Passed: a <GtkIMContext>.
Passed: a string.
text surrounding the insertion point, as UTF-8. the preedit string should not be included within text
Passed: a 32-bit integer.
the length of text, or -1 if text is nul-terminated
Passed: a 32-bit integer.
the byte index of the insertion cursor within text
Passed: a 32-bit integer.
the byte index of the selection bound within text
Sets whether the IM context should use the preedit string to display feedback.
If use-preedit is #f (default is #t), then the IM
context may use some other method to display feedback, such as
displaying it in a child of the root window.
Passed: a <GtkIMContext>.
Passed: a boolean.
whether the IM context should use the preedit string.
Connect a handler with (connect object imcontext:commit handler).
It is called as (handler self str).
The ::commit signal is emitted when a complete input sequence has been entered by the user.
If the commit comes after a preediting sequence, the ::commit signal is emitted after ::preedit-end.
This can be a single character immediately after a key press or the final result of preediting.
Passed: a <GtkIMContext>.
Passed: a string.
the completed character(s) entered by the user
Connect a handler with (connect object
imcontext:delete-surrounding handler). It is called as (handler
self offset n-chars) ⇒ %return.
The ::delete-surrounding signal is emitted when the input method needs to delete all or part of the context surrounding the cursor.
Passed: a <GtkIMContext>.
Passed: a 32-bit integer.
the character offset from the cursor position of the text to be deleted. A negative value indicates a position before the cursor.
Passed: a 32-bit integer.
the number of characters to be deleted
Returned: a boolean.
#t if the signal was handled.
Connect a handler with (connect object
imcontext:invalid-composition handler). It is called as (handler
self str) ⇒ %return.
Emitted when the filtered keys do not compose to a single valid character.
Passed: a <GtkIMContext>.
Passed: a string.
the completed character(s) entered by the user
Returned: a boolean.
true if the IM context avoid beeping on invalid composition
Connect a handler with (connect object imcontext:preedit-changed
handler). It is called as (handler self).
The ::preedit-changed signal is emitted whenever the preedit sequence currently being entered has changed.
It is also emitted at the end of a preedit sequence, in which case
imcontext:get-preedit-string
returns the empty string.
Passed: a <GtkIMContext>.
Connect a handler with (connect object imcontext:preedit-end
handler). It is called as (handler self).
The ::preedit-end signal is emitted when a preediting sequence has been completed or canceled.
Passed: a <GtkIMContext>.
Connect a handler with (connect object imcontext:preedit-start
handler). It is called as (handler self).
The ::preedit-start signal is emitted when a new preediting sequence starts.
Passed: a <GtkIMContext>.
Connect a handler with (connect object
imcontext:retrieve-surrounding handler). It is called as
(handler self) ⇒ %return.
The ::retrieve-surrounding signal is emitted when the input method requires the context surrounding the cursor.
The callback should set the input method surrounding context by calling
the imcontext:set-surrounding
method.
Passed: a <GtkIMContext>.
Returned: a boolean.
#t if the signal was handled.
To override it in a new class, give register-type #:vfuncs
`((activate-osk . ,procedure)). The procedure is called as
(procedure self).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
To override it in a new class, give register-type #:vfuncs
`((activate-osk-with-event . ,procedure)). The procedure is called as
(procedure self event) ⇒ %return.
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Passed: a <GdkEvent>.
Returned: a boolean.
Default handler of the imcontext:commit signal.
To override it in a new class, give register-type #:vfuncs
`((commit . ,procedure)). The procedure is called as (procedure
self str).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Passed: a string.
Asks the widget that the input context is attached to delete characters
around the cursor position by emitting the ::delete_surrounding
signal.
Note that offset and n-chars are in characters not in bytes
which differs from the usage other places in
<GtkIMContext>.
In order to use this function, you should first call
imcontext:get-surrounding to get
the current context, and call this function immediately afterwards to
make sure that you know what you are deleting. You should also account
for the fact that even if the signal was handled, the input context
might not have deleted all the characters that were requested to be
deleted.
This function is used by an input method that wants to make substitutions in the existing text in response to new input. It is not useful for applications.
To override it in a new class, give register-type #:vfuncs
`((delete-surrounding . ,procedure)). The procedure is called as
(procedure self offset n-chars) ⇒ %return.
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Passed: a 32-bit integer.
offset from cursor position in chars; a negative value means start before the cursor.
Passed: a 32-bit integer.
number of characters to delete.
Returned: a boolean.
#t if the signal was handled.
Allow an input method to internally handle key press and release events.
If this function returns #t, then no further processing should be
done for this key event.
To override it in a new class, give register-type #:vfuncs
`((filter-keypress . ,procedure)). The procedure is called as
(procedure self event) ⇒ %return.
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Passed: a <GdkEvent>.
the key event
Returned: a boolean.
#t if the input method handled the key event.
Notify the input method that the widget to which this input context corresponds has gained focus.
The input method may, for example, change the displayed feedback to reflect this change.
To override it in a new class, give register-type #:vfuncs
`((focus-in . ,procedure)). The procedure is called as
(procedure self).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Notify the input method that the widget to which this input context corresponds has lost focus.
The input method may, for example, change the displayed feedback or reset the contexts state to reflect this change.
To override it in a new class, give register-type #:vfuncs
`((focus-out . ,procedure)). The procedure is called as
(procedure self).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Retrieve the current preedit string for the input context, and a list of attributes to apply to the string.
This string should be displayed inserted at the insertion point.
To override it in a new class, give register-type #:vfuncs
`((get-preedit-string . ,procedure)). The procedure is called as
(procedure self) ⇒ str attrs cursor-pos.
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Returned: a string.
location to store the retrieved string. The string retrieved must be
freed with byte-array:free.
Returned: a <PangoAttrList>.
location to store the retrieved attribute list. When you are done with
this list, you must unreference it with attr-list:unref.
Returned: a 32-bit integer.
location to store position of cursor (in characters) within the preedit string.
Retrieves context around the insertion point.
Input methods typically want context in order to constrain input text based on existing text; this is important for languages such as Thai where only some sequences of characters are allowed.
This function is implemented by emitting the imcontext:retrieve-surrounding signal on the
input method; in response to this signal, a widget should provide as
much context as is available, up to an entire paragraph, by calling
imcontext:set-surrounding.
Note that there is no obligation for a widget to respond to the
::retrieve-surrounding signal, so input methods must be prepared
to function without context.
To override it in a new class, give register-type #:vfuncs
`((get-surrounding . ,procedure)). The procedure is called as
(procedure self) ⇒ %return text cursor-index.
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Returned: a boolean.
TRUE if surrounding text was provided; in this case you must free
the result stored in text.
Returned: a string.
location to store a UTF-8 encoded string of text holding context around
the insertion point. If the function returns #t, then you must
free the result stored in this location with
byte-array:free.
Returned: a 32-bit integer.
location to store byte index of the insertion cursor within text.
Retrieves context around the insertion point.
Input methods typically want context in order to constrain input text based on existing text; this is important for languages such as Thai where only some sequences of characters are allowed.
This function is implemented by emitting the imcontext:retrieve-surrounding signal on the
input method; in response to this signal, a widget should provide as
much context as is available, up to an entire paragraph, by calling
imcontext:set-surrounding-with-selection.
Note that there is no obligation for a widget to respond to the
::retrieve-surrounding signal, so input methods must be prepared
to function without context.
To override it in a new class, give register-type #:vfuncs
`((get-surrounding-with-selection . ,procedure)). The procedure is
called as (procedure self) ⇒ %return text cursor-index
anchor-index.
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Returned: a boolean.
TRUE if surrounding text was provided; in this case you must free
the result stored in text.
Returned: a string.
location to store a UTF-8 encoded string of text holding context around
the insertion point. If the function returns #t, then you must
free the result stored in this location with
byte-array:free.
Returned: a 32-bit integer.
location to store byte index of the insertion cursor within text.
Returned: a 32-bit integer.
location to store byte index of the selection bound within text
Default handler of the imcontext:invalid-composition signal. Since:
4.22
To override it in a new class, give register-type #:vfuncs
`((invalid-composition . ,procedure)). The procedure is called as
(procedure self str) ⇒ %return.
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Passed: a string.
Returned: a boolean.
Default handler of the imcontext:preedit-changed signal.
To override it in a new class, give register-type #:vfuncs
`((preedit-changed . ,procedure)). The procedure is called as
(procedure self).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Default handler of the imcontext:preedit-end signal.
To override it in a new class, give register-type #:vfuncs
`((preedit-end . ,procedure)). The procedure is called as
(procedure self).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Default handler of the imcontext:preedit-start signal.
To override it in a new class, give register-type #:vfuncs
`((preedit-start . ,procedure)). The procedure is called as
(procedure self).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Notify the input method that a change such as a change in cursor position has been made.
This will typically cause the input method to clear the preedit state.
To override it in a new class, give register-type #:vfuncs
`((reset . ,procedure)). The procedure is called as (procedure
self).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Default handler of the imcontext:retrieve-surrounding signal.
To override it in a new class, give register-type #:vfuncs
`((retrieve-surrounding . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Returned: a boolean.
Set the client widget for the input context.
This is the <GtkWidget> holding the input focus.
This widget is used in order to correctly position status windows, and
may also be used for purposes internal to the input method.
To override it in a new class, give register-type #:vfuncs
`((set-client-widget . ,procedure)). The procedure is called as
(procedure self widget).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Passed, or left out: a <GtkWidget>, or #f.
the client widget. This may be #f to indicate that the previous
client widget no longer exists.
Notify the input method that a change in cursor position has been made.
The location is relative to the client widget.
To override it in a new class, give register-type #:vfuncs
`((set-cursor-location . ,procedure)). The procedure is called as
(procedure self area).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Passed: a <GdkRectangle>.
new location
Sets surrounding context around the insertion point and preedit string.
This function is expected to be called in response to the
imcontext:retrieve-surrounding signal, and will
likely have no effect if called at other times.
To override it in a new class, give register-type #:vfuncs
`((set-surrounding . ,procedure)). The procedure is called as
(procedure self text len cursor-index).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Passed: a string.
text surrounding the insertion point, as UTF-8. the preedit string should not be included within text
Passed: a 32-bit integer.
the length of text, or -1 if text is nul-terminated
Passed: a 32-bit integer.
the byte index of the insertion cursor within text.
Sets surrounding context around the insertion point and preedit string.
This function is expected to be called in response to the
"retrieve_surrounding" signal, and will likely have no effect if
called at other times.
To override it in a new class, give register-type #:vfuncs
`((set-surrounding-with-selection . ,procedure)). The procedure is
called as (procedure self text len cursor-index anchor-index).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Passed: a string.
text surrounding the insertion point, as UTF-8. the preedit string should not be included within text
Passed: a 32-bit integer.
the length of text, or -1 if text is nul-terminated
Passed: a 32-bit integer.
the byte index of the insertion cursor within text
Passed: a 32-bit integer.
the byte index of the selection bound within text
Sets whether the IM context should use the preedit string to display feedback.
If use-preedit is #f (default is #t), then the IM
context may use some other method to display feedback, such as
displaying it in a child of the root window.
To override it in a new class, give register-type #:vfuncs
`((set-use-preedit . ,procedure)). The procedure is called as
(procedure self use-preedit).
Passed: the class whose implementation to call:
<GtkIMContext>, or a class that derives from it,
or its GType number.
Passed: a <GtkIMContext>.
Passed: a boolean.
whether the IM context should use the preedit string.