Trait gtk4::subclass::im_context::IMContextImpl

source ·
pub trait IMContextImpl: IMContextImplExt + ObjectImpl {
Show 18 methods // Provided methods fn commit(&self, string: &str) { ... } fn delete_surrounding(&self, offset: i32, n_chars: i32) -> bool { ... } fn filter_keypress(&self, event: &Event) -> bool { ... } fn focus_in(&self) { ... } fn focus_out(&self) { ... } fn preedit_string(&self) -> (GString, AttrList, i32) { ... } fn surrounding(&self) -> Option<(GString, i32)> { ... } fn preedit_changed(&self) { ... } fn preedit_end(&self) { ... } fn preedit_start(&self) { ... } fn reset(&self) { ... } fn retrieve_surrounding(&self) -> bool { ... } fn set_client_widget<P: IsA<Widget>>(&self, widget: Option<&P>) { ... } fn set_cursor_location(&self, area: &Rectangle) { ... } fn set_surrounding(&self, text: &str, cursor_index: i32) { ... } fn set_use_preedit(&self, use_preedit: bool) { ... } fn activate_osk(&self) { ... } fn activate_osk_with_event(&self, event: Option<&Event>) -> bool { ... }
}

Provided Methods§

source

fn commit(&self, string: &str)

Default handler of the commit signal.

source

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 IMContextExt::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.

source

fn filter_keypress(&self, event: &Event) -> bool

Allow an input method to internally handle key press and release events.

If this function returns true, then no further processing should be done for this key event.

§event

the key event

§Returns

true if the input method handled the key event.

source

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.

source

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.

source

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.

source

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 IMContextExt::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 IMContextExt::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.

source

fn preedit_changed(&self)

Default handler of the preedit-changed signal.

source

fn preedit_end(&self)

Default handler of the preedit-end signal.

source

fn preedit_start(&self)

Default handler of the preedit-start signal.

source

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.

source

fn retrieve_surrounding(&self) -> bool

Default handler of the retrieve-surrounding signal.

source

fn set_client_widget<P: IsA<Widget>>(&self, widget: Option<&P>)

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.

source

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

source

fn set_surrounding(&self, text: &str, cursor_index: i32)

👎Deprecated: Since 4.2

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 IMContextExt::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.

source

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.

source

fn activate_osk(&self)

Available on crate feature v4_10 only.
source

fn activate_osk_with_event(&self, event: Option<&Event>) -> bool

Available on crate feature v4_14 only.

Object Safety§

This trait is not object safe.

Implementors§