WebKit2.InputMethodContext

g GObject.Object GObject.Object WebKit2.InputMethodContext WebKit2.InputMethodContext GObject.Object->WebKit2.InputMethodContext

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

filter_key_event (key_event)

get_input_hints ()

get_input_purpose ()

get_preedit ()

notify_cursor_area (x, y, width, height)

notify_focus_in ()

notify_focus_out ()

notify_surrounding (text, length, cursor_index, selection_index)

reset ()

set_enable_preedit (enabled)

set_input_hints (hints)

set_input_purpose (purpose)

Virtual Methods

Inherited:

GObject.Object (7)

do_committed (text)

do_delete_surrounding (offset, n_chars)

do_filter_key_event (key_event)

do_get_preedit ()

do_notify_cursor_area (x, y, width, height)

do_notify_focus_in ()

do_notify_focus_out ()

do_notify_surrounding (text, length, cursor_index, selection_index)

do_preedit_changed ()

do_preedit_finished ()

do_preedit_started ()

do_reset ()

do_set_enable_preedit (enabled)

Properties

Name

Type

Flags

Short Description

input-hints

WebKit2.InputHints

r/w

input-purpose

WebKit2.InputPurpose

r/w

Signals

Inherited:

GObject.Object (1)

Name

Short Description

committed

Emitted when a complete input sequence has been entered by the user.

delete-surrounding

Emitted when the input method wants to delete the context surrounding the cursor.

preedit-changed

Emitted whenever the preedit sequence currently being entered has changed.

preedit-finished

Emitted when a preediting sequence has been completed or canceled.

preedit-started

Emitted when a new preediting sequence starts.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class WebKit2.InputMethodContext(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

WebKit2.InputMethodContextClass

Base class for input method contexts.

WebKit2.InputMethodContext 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.

New in version 2.28.

filter_key_event(key_event)
Parameters:

key_event (Gdk.EventKey) – the key event to filter

Returns:

True if the key event was handled, or False otherwise

Return type:

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.

New in version 2.28.

get_input_hints()
Returns:

the WebKit2.InputHints of the input associated with self

Return type:

WebKit2.InputHints

Get the value of the WebKit2.InputMethodContext :input-hints property.

New in version 2.28.

get_input_purpose()
Returns:

the WebKit2.InputPurpose of the input associated with self

Return type:

WebKit2.InputPurpose

Get the value of the WebKit2.InputMethodContext :input-purpose property.

New in version 2.28.

get_preedit()
Returns:

text:

location to store the preedit string

underlines:

location to store the underlines as a GLib.List of WebKit2.InputMethodUnderline

cursor_offset:

location to store the position of cursor in preedit string

Return type:

(text: str or None, underlines: [WebKit2.InputMethodUnderline], cursor_offset: int)

Get the pre-edit string and a list of WebKit2.InputMethodUnderline.

Get the current pre-edit string for the self, and a list of WebKit2.InputMethodUnderline to apply to the string. The string will be displayed inserted at cursor_offset.

New in version 2.28.

notify_cursor_area(x, y, width, height)
Parameters:
  • x (int) – the x coordinate of cursor location

  • y (int) – the y coordinate of cursor location

  • width (int) – the width of cursor area

  • height (int) – the height of cursor area

Notify self that cursor area changed in input associated.

New in version 2.28.

notify_focus_in()

Notify self that input associated has gained focus.

New in version 2.28.

notify_focus_out()

Notify self that input associated has lost focus.

New in version 2.28.

notify_surrounding(text, length, cursor_index, selection_index)
Parameters:
  • text (str) – text surrounding the insertion point

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

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

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

Notify self that the context surrounding the cursor has changed.

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

New in version 2.28.

reset()

Reset the self.

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

New in version 2.28.

set_enable_preedit(enabled)
Parameters:

enabled (bool) – whether to enable preedit

Set whether self should enable preedit to display feedback.

New in version 2.28.

set_input_hints(hints)
Parameters:

hints (WebKit2.InputHints) – a WebKit2.InputHints

Set the value of the WebKit2.InputMethodContext :input-hints property.

New in version 2.28.

set_input_purpose(purpose)
Parameters:

purpose (WebKit2.InputPurpose) – a WebKit2.InputPurpose

Set the value of the WebKit2.InputMethodContext :input-purpose property.

New in version 2.28.

do_committed(text) virtual
Parameters:

text (str) –

do_delete_surrounding(offset, n_chars) virtual
Parameters:
  • offset (int) –

  • n_chars (int) –

do_filter_key_event(key_event) virtual
Parameters:

key_event (Gdk.EventKey) – the key event to filter

Returns:

True if the key event was handled, or False otherwise

Return type:

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.

New in version 2.28.

do_get_preedit() virtual
Returns:

text:

location to store the preedit string

underlines:

location to store the underlines as a GLib.List of WebKit2.InputMethodUnderline

cursor_offset:

location to store the position of cursor in preedit string

Return type:

(text: str or None, underlines: [WebKit2.InputMethodUnderline], cursor_offset: int)

Get the pre-edit string and a list of WebKit2.InputMethodUnderline.

Get the current pre-edit string for the context, and a list of WebKit2.InputMethodUnderline to apply to the string. The string will be displayed inserted at cursor_offset.

New in version 2.28.

do_notify_cursor_area(x, y, width, height) virtual
Parameters:
  • x (int) – the x coordinate of cursor location

  • y (int) – the y coordinate of cursor location

  • width (int) – the width of cursor area

  • height (int) – the height of cursor area

Notify context that cursor area changed in input associated.

New in version 2.28.

do_notify_focus_in() virtual

Notify context that input associated has gained focus.

New in version 2.28.

do_notify_focus_out() virtual

Notify context that input associated has lost focus.

New in version 2.28.

do_notify_surrounding(text, length, cursor_index, selection_index) virtual
Parameters:
  • text (str) – text surrounding the insertion point

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

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

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

Notify context that the context surrounding the cursor has changed.

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

New in version 2.28.

do_preedit_changed() virtual
do_preedit_finished() virtual
do_preedit_started() virtual
do_reset() virtual

Reset the context.

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

New in version 2.28.

do_set_enable_preedit(enabled) virtual
Parameters:

enabled (bool) – whether to enable preedit

Set whether context should enable preedit to display feedback.

New in version 2.28.

Signal Details

WebKit2.InputMethodContext.signals.committed(input_method_context, text)
Signal Name:

committed

Flags:

RUN_LAST

Parameters:

Emitted when a complete input sequence has been entered by the user. This can be a single character immediately after a key press or the final result of preediting.

New in version 2.28.

WebKit2.InputMethodContext.signals.delete_surrounding(input_method_context, offset, n_chars)
Signal Name:

delete-surrounding

Flags:

RUN_LAST

Parameters:
  • input_method_context (WebKit2.InputMethodContext) – The object which received the signal

  • offset (int) – the character offset from the cursor position of the text to be deleted.

  • n_chars (int) – the number of characters to be deleted

Emitted when the input method wants to delete the context surrounding the cursor. If offset is a negative value, it means a position before the cursor.

New in version 2.28.

WebKit2.InputMethodContext.signals.preedit_changed(input_method_context)
Signal Name:

preedit-changed

Flags:

RUN_LAST

Parameters:

input_method_context (WebKit2.InputMethodContext) – The object which received the signal

Emitted whenever the preedit sequence currently being entered has changed. It is also emitted at the end of a preedit sequence, in which case WebKit2.InputMethodContext.get_preedit() returns the empty string.

New in version 2.28.

WebKit2.InputMethodContext.signals.preedit_finished(input_method_context)
Signal Name:

preedit-finished

Flags:

RUN_LAST

Parameters:

input_method_context (WebKit2.InputMethodContext) – The object which received the signal

Emitted when a preediting sequence has been completed or canceled.

New in version 2.28.

WebKit2.InputMethodContext.signals.preedit_started(input_method_context)
Signal Name:

preedit-started

Flags:

RUN_LAST

Parameters:

input_method_context (WebKit2.InputMethodContext) – The object which received the signal

Emitted when a new preediting sequence starts.

New in version 2.28.

Property Details

WebKit2.InputMethodContext.props.input_hints
Name:

input-hints

Type:

WebKit2.InputHints

Default Value:

WebKit2.InputHints.NONE

Flags:

READABLE, WRITABLE

The WebKit2.InputHints of the input associated with this context.

New in version 2.28.

WebKit2.InputMethodContext.props.input_purpose
Name:

input-purpose

Type:

WebKit2.InputPurpose

Default Value:

WebKit2.InputPurpose.FREE_FORM

Flags:

READABLE, WRITABLE

The WebKit2.InputPurpose of the input associated with this context.

New in version 2.28.