Trait gtk4::prelude::IMContextExt
source · pub trait IMContextExt: IsA<IMContext> + Sealed + 'static {
Show 26 methods
// Provided methods
fn delete_surrounding(&self, offset: i32, n_chars: i32) -> bool { ... }
fn filter_key(
&self,
press: bool,
surface: &impl IsA<Surface>,
device: &Device,
time: u32,
keycode: u32,
state: ModifierType,
group: i32
) -> bool { ... }
fn filter_keypress(&self, event: impl AsRef<Event>) -> bool { ... }
fn focus_in(&self) { ... }
fn focus_out(&self) { ... }
fn preedit_string(&self) -> (GString, AttrList, i32) { ... }
fn surrounding(&self) -> Option<(GString, i32)> { ... }
fn surrounding_with_selection(&self) -> Option<(GString, i32, i32)> { ... }
fn reset(&self) { ... }
fn set_client_widget(&self, widget: Option<&impl IsA<Widget>>) { ... }
fn set_cursor_location(&self, area: &Rectangle) { ... }
fn set_surrounding(&self, text: &str, cursor_index: i32) { ... }
fn set_surrounding_with_selection(
&self,
text: &str,
cursor_index: i32,
anchor_index: i32
) { ... }
fn set_use_preedit(&self, use_preedit: bool) { ... }
fn input_hints(&self) -> InputHints { ... }
fn set_input_hints(&self, input_hints: InputHints) { ... }
fn input_purpose(&self) -> InputPurpose { ... }
fn set_input_purpose(&self, input_purpose: InputPurpose) { ... }
fn connect_commit<F: Fn(&Self, &str) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_delete_surrounding<F: Fn(&Self, i32, i32) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_preedit_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_preedit_end<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_preedit_start<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_retrieve_surrounding<F: Fn(&Self) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_input_hints_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
}
Expand description
Provided Methods§
sourcefn delete_surrounding(&self, offset: i32, n_chars: i32) -> bool
fn delete_surrounding(&self, offset: i32, n_chars: i32) -> bool
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 IMContext
.
In order to use this function, you should first call
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.
offset
offset from cursor position in chars; a negative value means start before the cursor.
n_chars
number of characters to delete.
Returns
true
if the signal was handled.
sourcefn filter_key(
&self,
press: bool,
surface: &impl IsA<Surface>,
device: &Device,
time: u32,
keycode: u32,
state: ModifierType,
group: i32
) -> bool
fn filter_key( &self, press: bool, surface: &impl IsA<Surface>, device: &Device, time: u32, keycode: u32, state: ModifierType, group: i32 ) -> bool
Allow an input method to forward key press and release events
to another input method without necessarily having a gdk::Event
available.
press
whether to forward a key press or release event
surface
the surface the event is for
device
the device that the event is for
time
the timestamp for the event
keycode
the keycode for the event
state
modifier state for the event
group
the active keyboard group for the event
Returns
true
if the input method handled the key event.
sourcefn filter_keypress(&self, event: impl AsRef<Event>) -> bool
fn filter_keypress(&self, event: impl AsRef<Event>) -> bool
sourcefn focus_in(&self)
fn focus_in(&self)
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.
sourcefn focus_out(&self)
fn focus_out(&self)
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.
sourcefn preedit_string(&self) -> (GString, AttrList, i32)
fn preedit_string(&self) -> (GString, AttrList, i32)
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.
Returns
str
location to store the retrieved string. The string retrieved must be freed with g_free().
attrs
location to store the retrieved
attribute list. When you are done with this list, you
must unreference it with Pango::AttrList::unref()
.
cursor_pos
location to store position of cursor (in characters) within the preedit string.
sourcefn surrounding(&self) -> Option<(GString, i32)>
fn surrounding(&self) -> Option<(GString, i32)>
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
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
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.
Deprecated since 4.2
Use surrounding_with_selection()
instead.
Returns
TRUE
if surrounding text was provided; in this case
you must free the result stored in text
.
text
location to store a UTF-8 encoded
string of text holding context around the insertion point.
If the function returns true
, then you must free the result
stored in this location with g_free().
cursor_index
location to store byte index of the insertion cursor within @text.
sourcefn surrounding_with_selection(&self) -> Option<(GString, i32, i32)>
fn surrounding_with_selection(&self) -> Option<(GString, i32, i32)>
v4_2
only.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
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
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.
Returns
TRUE
if surrounding text was provided; in this case
you must free the result stored in text
.
text
location to store a UTF-8 encoded
string of text holding context around the insertion point.
If the function returns true
, then you must free the result
stored in this location with g_free().
cursor_index
location to store byte index of the insertion cursor within @text.
anchor_index
location to store byte index of the selection bound within @text
sourcefn reset(&self)
fn reset(&self)
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.
sourcefn set_client_widget(&self, widget: Option<&impl IsA<Widget>>)
fn set_client_widget(&self, widget: Option<&impl IsA<Widget>>)
Set the client widget for the input context.
This is the Widget
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.
widget
the client widget. This may be None
to indicate
that the previous client widget no longer exists.
sourcefn set_cursor_location(&self, area: &Rectangle)
fn set_cursor_location(&self, area: &Rectangle)
Notify the input method that a change in cursor position has been made.
The location is relative to the client widget.
area
new location
sourcefn set_surrounding(&self, text: &str, cursor_index: i32)
fn set_surrounding(&self, text: &str, cursor_index: i32)
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.
Deprecated since 4.2
Use set_surrounding_with_selection()
instead
text
text surrounding the insertion point, as UTF-8. the preedit string should not be included within @text
len
the length of @text, or -1 if @text is nul-terminated
cursor_index
the byte index of the insertion cursor within @text.
sourcefn set_surrounding_with_selection(
&self,
text: &str,
cursor_index: i32,
anchor_index: i32
)
fn set_surrounding_with_selection( &self, text: &str, cursor_index: i32, anchor_index: i32 )
v4_2
only.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.
text
text surrounding the insertion point, as UTF-8. the preedit string should not be included within @text
len
the length of @text, or -1 if @text is nul-terminated
cursor_index
the byte index of the insertion cursor within @text
anchor_index
the byte index of the selection bound within @text
sourcefn set_use_preedit(&self, use_preedit: bool)
fn set_use_preedit(&self, use_preedit: bool)
Sets whether the IM context should use the preedit string to display feedback.
If @use_preedit is false
(default is true
), then the IM context
may use some other method to display feedback, such as displaying
it in a child of the root window.
use_preedit
whether the IM context should use the preedit string.
sourcefn input_hints(&self) -> InputHints
fn input_hints(&self) -> InputHints
Additional hints that allow input methods to fine-tune their behaviour.
sourcefn set_input_hints(&self, input_hints: InputHints)
fn set_input_hints(&self, input_hints: InputHints)
Additional hints that allow input methods to fine-tune their behaviour.
sourcefn input_purpose(&self) -> InputPurpose
fn input_purpose(&self) -> InputPurpose
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.
sourcefn set_input_purpose(&self, input_purpose: InputPurpose)
fn set_input_purpose(&self, input_purpose: InputPurpose)
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.
sourcefn connect_commit<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_commit<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId
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.
str
the completed character(s) entered by the user
sourcefn connect_delete_surrounding<F: Fn(&Self, i32, i32) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_delete_surrounding<F: Fn(&Self, i32, i32) -> bool + 'static>( &self, f: F ) -> SignalHandlerId
The ::delete-surrounding signal is emitted when the input method needs to delete all or part of the context surrounding the cursor.
offset
the character offset from the cursor position of the text to be deleted. A negative value indicates a position before the cursor.
n_chars
the number of characters to be deleted
Returns
true
if the signal was handled.
sourcefn connect_preedit_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_preedit_changed<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId
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
preedit_string()
returns the empty string.
sourcefn connect_preedit_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_preedit_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
The ::preedit-end signal is emitted when a preediting sequence has been completed or canceled.
sourcefn connect_preedit_start<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_preedit_start<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
The ::preedit-start signal is emitted when a new preediting sequence starts.
sourcefn connect_retrieve_surrounding<F: Fn(&Self) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_retrieve_surrounding<F: Fn(&Self) -> bool + 'static>( &self, f: F ) -> SignalHandlerId
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 set_surrounding()
method.
Returns
true
if the signal was handled.