InputMethodContext#

Added in version 2.28.

class InputMethodContext(**properties: Any)#

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_committed(self, text: str) None#
Parameters:

text

do_delete_surrounding(self, offset: int, n_chars: int) None#
Parameters:
  • offset

  • n_chars

do_filter_key_event(self, key_event: Event) bool#
Parameters:

key_event

do_get_preedit(self) Tuple[str | None, list[InputMethodUnderline] | None, int | None]#
do_notify_cursor_area(self, x: int, y: int, width: int, height: int) None#
Parameters:
  • x

  • y

  • width

  • height

do_notify_focus_in(self) None#
do_notify_focus_out(self) None#
do_notify_surrounding(self, text: str, length: int, cursor_index: int, selection_index: int) None#
Parameters:
  • text

  • length

  • cursor_index

  • selection_index

do_preedit_changed(self) None#
do_preedit_finished(self) None#
do_preedit_started(self) None#
do_reset(self) None#
do_set_enable_preedit(self, enabled: bool) None#
Parameters:

enabled

filter_key_event(key_event: Event) bool#

Allow key_event to be handled by the input method.

If True is 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 at cursor_offset.

Added in version 2.28.

notify_cursor_area(x: int, y: int, width: int, height: int) None#

Notify context that 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 context that input associated has gained focus.

Added in version 2.28.

notify_focus_out() None#

Notify context that input associated has lost focus.

Added in version 2.28.

notify_surrounding(text: str, length: int, cursor_index: int, selection_index: int) None#

Notify context that the context surrounding the cursor has changed.

If there’s no selection selection_index is the same as cursor_index.

Added in version 2.28.

Parameters:
  • text – text surrounding the insertion point

  • length – the length of text, or -1 if text is nul-terminated

  • cursor_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 context should 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

delete_surrounding(offset: int, n_chars: int) None#

The type of the None singleton.

Added in version 2.28.

Parameters:
  • offset – the character offset from the cursor position of the text to be deleted.

  • n_chars – the number of characters to be deleted

preedit_changed() None#

The type of the None singleton.

Added in version 2.28.

preedit_finished() None#

The type of the None singleton.

Added in version 2.28.

preedit_started() None#

The type of the None singleton.

Added in version 2.28.

Virtual Methods#

class InputMethodContext
do_committed(text: str) None#

The type of the None singleton.

Parameters:

text

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_event to be handled by the input method.

If True is 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 at cursor_offset.

Added in version 2.28.

do_notify_cursor_area(x: int, y: int, width: int, height: int) None#

Notify context that 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 context that input associated has gained focus.

Added in version 2.28.

do_notify_focus_out() None#

Notify context that 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 context that the context surrounding the cursor has changed.

If there’s no selection selection_index is the same as cursor_index.

Added in version 2.28.

Parameters:
  • text – text surrounding the insertion point

  • length – the length of text, or -1 if text is nul-terminated

  • cursor_index – the byte index of the insertion cursor within text.

  • selection_index – the byte index of the selection cursor within text.

do_preedit_changed() None#

The type of the None singleton.

do_preedit_finished() None#

The type of the None singleton.

do_preedit_started() None#

The type of the None singleton.

do_reset() None#

Reset the context.

This will typically cause the input to clear the preedit state.

Added in version 2.28.

do_set_enable_preedit(enabled: bool) None#

Set whether context should enable preedit to display feedback.

Added in version 2.28.

Parameters:

enabled – whether to enable preedit

Fields#

class InputMethodContext
parent_instance#
priv#