:right-sidebar: True InputMethodContext =================================================================== .. currentmodule:: gi.repository.WebKit .. versionadded:: 2.28 .. class:: InputMethodContext(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.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 ------- .. rst-class:: interim-class .. class:: InputMethodContext :no-index: .. method:: do_committed(self, text: str) -> None :param text: .. method:: do_delete_surrounding(self, offset: int, n_chars: int) -> None :param offset: :param n_chars: .. method:: do_filter_key_event(self, key_event: ~gi.repository.Gdk.Event) -> bool :param key_event: .. method:: do_get_preedit(self) -> ~typing.Tuple[str | None, list[~gi.repository.WebKit.InputMethodUnderline] | None, int | None] .. method:: do_notify_cursor_area(self, x: int, y: int, width: int, height: int) -> None :param x: :param y: :param width: :param height: .. method:: do_notify_focus_in(self) -> None .. method:: do_notify_focus_out(self) -> None .. method:: do_notify_surrounding(self, text: str, length: int, cursor_index: int, selection_index: int) -> None :param text: :param length: :param cursor_index: :param selection_index: .. method:: do_preedit_changed(self) -> None .. method:: do_preedit_finished(self) -> None .. method:: do_preedit_started(self) -> None .. method:: do_reset(self) -> None .. method:: do_set_enable_preedit(self, enabled: bool) -> None :param enabled: .. method:: filter_key_event(key_event: ~gi.repository.Gdk.Event) -> bool Allow ``key_event`` to be handled by the input method. If :const:`True` is returned, then no further processing should be done for the key event. .. versionadded:: 2.28 :param key_event: the key event to filter .. method:: get_input_hints() -> ~gi.repository.WebKit.InputHints Get the value of the :obj:`~gi.repository.WebKit.InputMethodContext`\:input-hints property. .. versionadded:: 2.28 .. method:: get_input_purpose() -> ~gi.repository.WebKit.InputPurpose Get the value of the :obj:`~gi.repository.WebKit.InputMethodContext`\:input-purpose property. .. versionadded:: 2.28 .. method:: get_preedit() -> ~typing.Tuple[str | None, list[~gi.repository.WebKit.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``\. .. versionadded:: 2.28 .. method:: notify_cursor_area(x: int, y: int, width: int, height: int) -> None Notify ``context`` that cursor area changed in input associated. .. versionadded:: 2.28 :param x: the x coordinate of cursor location :param y: the y coordinate of cursor location :param width: the width of cursor area :param height: the height of cursor area .. method:: notify_focus_in() -> None Notify ``context`` that input associated has gained focus. .. versionadded:: 2.28 .. method:: notify_focus_out() -> None Notify ``context`` that input associated has lost focus. .. versionadded:: 2.28 .. method:: 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``\. .. versionadded:: 2.28 :param text: text surrounding the insertion point :param length: the length of ``text``\, or -1 if ``text`` is nul-terminated :param cursor_index: the byte index of the insertion cursor within ``text``\. :param selection_index: the byte index of the selection cursor within ``text``\. .. method:: reset() -> None Reset the ``context``\. This will typically cause the input to clear the preedit state. .. versionadded:: 2.28 .. method:: set_enable_preedit(enabled: bool) -> None Set whether ``context`` should enable preedit to display feedback. .. versionadded:: 2.28 :param enabled: whether to enable preedit .. method:: set_input_hints(hints: ~gi.repository.WebKit.InputHints) -> None Set the value of the :obj:`~gi.repository.WebKit.InputMethodContext`\:input-hints property. .. versionadded:: 2.28 :param hints: a :obj:`~gi.repository.WebKit.InputHints` .. method:: set_input_purpose(purpose: ~gi.repository.WebKit.InputPurpose) -> None Set the value of the :obj:`~gi.repository.WebKit.InputMethodContext`\:input-purpose property. .. versionadded:: 2.28 :param purpose: a :obj:`~gi.repository.WebKit.InputPurpose` Properties ---------- .. rst-class:: interim-class .. class:: InputMethodContext :no-index: .. attribute:: props.input_hints :type: ~gi.repository.WebKit.InputHints The type of the None singleton. .. versionadded:: 2.28 .. attribute:: props.input_purpose :type: ~gi.repository.WebKit.InputPurpose The type of the None singleton. .. versionadded:: 2.28 Signals ------- .. rst-class:: interim-class .. class:: InputMethodContext.signals :no-index: .. method:: committed(text: str) -> None The type of the None singleton. .. versionadded:: 2.28 :param text: the string result .. method:: delete_surrounding(offset: int, n_chars: int) -> None The type of the None singleton. .. versionadded:: 2.28 :param offset: the character offset from the cursor position of the text to be deleted. :param n_chars: the number of characters to be deleted .. method:: preedit_changed() -> None The type of the None singleton. .. versionadded:: 2.28 .. method:: preedit_finished() -> None The type of the None singleton. .. versionadded:: 2.28 .. method:: preedit_started() -> None The type of the None singleton. .. versionadded:: 2.28 Virtual Methods --------------- .. rst-class:: interim-class .. class:: InputMethodContext :no-index: .. method:: do_committed(text: str) -> None The type of the None singleton. :param text: .. method:: do_delete_surrounding(offset: int, n_chars: int) -> None The type of the None singleton. :param offset: :param n_chars: .. method:: do_filter_key_event(key_event: ~gi.repository.Gdk.Event) -> bool Allow ``key_event`` to be handled by the input method. If :const:`True` is returned, then no further processing should be done for the key event. .. versionadded:: 2.28 :param key_event: the key event to filter .. method:: do_get_preedit() -> ~typing.Tuple[str | None, list[~gi.repository.WebKit.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``\. .. versionadded:: 2.28 .. method:: do_notify_cursor_area(x: int, y: int, width: int, height: int) -> None Notify ``context`` that cursor area changed in input associated. .. versionadded:: 2.28 :param x: the x coordinate of cursor location :param y: the y coordinate of cursor location :param width: the width of cursor area :param height: the height of cursor area .. method:: do_notify_focus_in() -> None Notify ``context`` that input associated has gained focus. .. versionadded:: 2.28 .. method:: do_notify_focus_out() -> None Notify ``context`` that input associated has lost focus. .. versionadded:: 2.28 .. method:: 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``\. .. versionadded:: 2.28 :param text: text surrounding the insertion point :param length: the length of ``text``\, or -1 if ``text`` is nul-terminated :param cursor_index: the byte index of the insertion cursor within ``text``\. :param selection_index: the byte index of the selection cursor within ``text``\. .. method:: do_preedit_changed() -> None The type of the None singleton. .. method:: do_preedit_finished() -> None The type of the None singleton. .. method:: do_preedit_started() -> None The type of the None singleton. .. method:: do_reset() -> None Reset the ``context``\. This will typically cause the input to clear the preedit state. .. versionadded:: 2.28 .. method:: do_set_enable_preedit(enabled: bool) -> None Set whether ``context`` should enable preedit to display feedback. .. versionadded:: 2.28 :param enabled: whether to enable preedit Fields ------ .. rst-class:: interim-class .. class:: InputMethodContext :no-index: .. attribute:: parent_instance .. attribute:: priv