InputMethodContext#
Added in version 2.28.
Superclasses: Object
Base class for input method contexts.
WebKitInputMethodContext defines the interface to implement WebKit input methods. The input methods are used by WebKit, when editable content is focused, to map from key events to Unicode character strings.
An input method may consume multiple key events in sequence and finally output 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.
Methods#
- class InputMethodContext
-
- do_notify_cursor_area(self, x: int, y: int, width: int, height: int) None#
- Parameters:
x
y
width
height
- do_notify_surrounding(self, text: str, length: int, cursor_index: int, selection_index: int) None#
- Parameters:
text
length
cursor_index
selection_index
- filter_key_event(key_event: Event) bool#
Allow
key_eventto be handled by the input method.If
Trueis returned, then no further processing should be done for the key event.Added in version 2.28.
- Parameters:
key_event – the key event to filter
- get_input_hints() InputHints#
Get the value of the
InputMethodContext:input-hints property.Added in version 2.28.
- get_input_purpose() InputPurpose#
Get the value of the
InputMethodContext:input-purpose property.Added in version 2.28.
- get_preedit() tuple[str | None, list[InputMethodUnderline] | None, int | None]#
Get the pre-edit string and a list of WebKitInputMethodUnderline.
Get the current pre-edit string for the
context, and a list of WebKitInputMethodUnderline to apply to the string. The string will be displayed inserted atcursor_offset.Added in version 2.28.
- notify_cursor_area(x: int, y: int, width: int, height: int) None#
Notify
contextthat cursor area changed in input associated.Added in version 2.28.
- Parameters:
x – the x coordinate of cursor location
y – the y coordinate of cursor location
width – the width of cursor area
height – the height of cursor area
- notify_focus_in() None#
Notify
contextthat input associated has gained focus.Added in version 2.28.
- notify_focus_out() None#
Notify
contextthat input associated has lost focus.Added in version 2.28.
- notify_surrounding(text: str, length: int, cursor_index: int, selection_index: int) None#
Notify
contextthat the context surrounding the cursor has changed.If there’s no selection
selection_indexis the same ascursor_index.Added in version 2.28.
- Parameters:
text – text surrounding the insertion point
length – the length of
text, or -1 iftextis nul-terminatedcursor_index – the byte index of the insertion cursor within
text.selection_index – the byte index of the selection cursor within
text.
- reset() None#
Reset the
context.This will typically cause the input to clear the preedit state.
Added in version 2.28.
- set_enable_preedit(enabled: bool) None#
Set whether
contextshould enable preedit to display feedback.Added in version 2.28.
- Parameters:
enabled – whether to enable preedit
- set_input_hints(hints: InputHints) None#
Set the value of the
InputMethodContext:input-hints property.Added in version 2.28.
- Parameters:
hints – a
InputHints
- set_input_purpose(purpose: InputPurpose) None#
Set the value of the
InputMethodContext:input-purpose property.Added in version 2.28.
- Parameters:
purpose – a
InputPurpose
Properties#
- class InputMethodContext
- props.input_hints: InputHints#
The type of the None singleton.
Added in version 2.28.
- props.input_purpose: InputPurpose#
The type of the None singleton.
Added in version 2.28.
Signals#
- class InputMethodContext.signals
- committed(text: str) None#
The type of the None singleton.
Added in version 2.28.
- Parameters:
text – the string result
Virtual Methods#
- class InputMethodContext
-
- do_delete_surrounding(offset: int, n_chars: int) None#
The type of the None singleton.
- Parameters:
offset
n_chars
- do_filter_key_event(key_event: Event) bool#
Allow
key_eventto be handled by the input method.If
Trueis returned, then no further processing should be done for the key event.Added in version 2.28.
- Parameters:
key_event – the key event to filter
- do_get_preedit() tuple[str | None, list[InputMethodUnderline] | None, int | None]#
Get the pre-edit string and a list of WebKitInputMethodUnderline.
Get the current pre-edit string for the
context, and a list of WebKitInputMethodUnderline to apply to the string. The string will be displayed inserted atcursor_offset.Added in version 2.28.
- do_notify_cursor_area(x: int, y: int, width: int, height: int) None#
Notify
contextthat cursor area changed in input associated.Added in version 2.28.
- Parameters:
x – the x coordinate of cursor location
y – the y coordinate of cursor location
width – the width of cursor area
height – the height of cursor area
- do_notify_focus_in() None#
Notify
contextthat input associated has gained focus.Added in version 2.28.
- do_notify_focus_out() None#
Notify
contextthat input associated has lost focus.Added in version 2.28.
- do_notify_surrounding(text: str, length: int, cursor_index: int, selection_index: int) None#
Notify
contextthat the context surrounding the cursor has changed.If there’s no selection
selection_indexis the same ascursor_index.Added in version 2.28.
- Parameters:
text – text surrounding the insertion point
length – the length of
text, or -1 iftextis nul-terminatedcursor_index – the byte index of the insertion cursor within
text.selection_index – the byte index of the selection cursor within
text.