Trait gtk4::prelude::IMContextExt[][src]

pub trait IMContextExt: 'static {
Show 25 methods fn delete_surrounding(&self, offset: i32, n_chars: i32) -> bool;
fn filter_key<P: IsA<Surface>>(
        &self,
        press: bool,
        surface: &P,
        device: &Device,
        time: u32,
        keycode: u32,
        state: ModifierType,
        group: i32
    ) -> 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<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_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

Required methods

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 subsitutions 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.

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.

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.

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.

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.

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

This is supported on crate feature 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 signal::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 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

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.

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.

Notify the input method that a change in cursor position has been made.

The location is relative to the client widget.

area

new location

Sets surrounding context around the insertion point and preedit string.

This function is expected to be called in response to the signal::IMContext::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.

This is supported on crate feature v4_2 only.

Sets surrounding context around the insertion point and preedit string. This function is expected to be called in response to the signal::IMContext::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

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.

Additional hints that allow input methods to fine-tune their behaviour.

Additional hints that allow input methods to fine-tune their behaviour.

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.

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.

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

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.

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.

The ::preedit-end signal is emitted when a preediting sequence has been completed or canceled.

The ::preedit-start signal is emitted when a new preediting sequence starts.

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.

Implementors