Kanzi Engine API
kanzi::InputMethod Class Referenceabstract

The InputMethod class defines the interface of the Kanzi input methods. More...

#include <kanzi/core.ui/input_method/input_method.hpp>

Inheritance diagram for kanzi::InputMethod:
[legend]

Public Member Functions

void connect (InputMethodListener &listener, Node &attachedNode, string_view text, size_t cursorPosition, size_t selectionStart, size_t selectionEnd)
 Connects an input method listener to this input method. More...
 
void disconnect (InputMethodListener &listener)
 Disconnects the listener passed as argument. More...
 
InputMethodListenergetListener () const
 Returns the active listener of the input method. More...
 
bool isBlocked () const
 Checks whether the input method is blocked by another input method that is in the text composition state. More...
 
void notifyCompositionEnd (InputMethodListener &listener)
 Notifies the input method that text composition is completed or canceled on the listener. More...
 
void notifyCompositionStart (InputMethodListener &listener)
 Notifies the input method that text composition is started on the listener. More...
 
void notifyCursorMove (InputMethodListener &listener, size_t position)
 Notifies the input method about the cursor position change in a listener. More...
 
void notifyEnterKeyCancel (InputMethodListener &listener)
 Notifies the input method that the input method listener cancels the Enter key event. More...
 
void notifyEnterKeyLabelChange (InputMethodListener &listener, EnterKeyLabel label)
 Notifies the input method that the label of the Enter key associated with the input method listener changed. More...
 
void notifyEnterKeyPress (InputMethodListener &listener)
 Notifies the input method that the input method listener handles the Enter key press event. More...
 
void notifyEnterKeyRelease (InputMethodListener &listener)
 Notifies the input method that the input method listener handles the Enter key release event. More...
 
bool notifyInputTypeAttributesChange (InputMethodListener &listener, EchoMode echoMode, InputType inputType)
 Notifies the input method that the input type attributes of the listener changed. More...
 
void notifyReadOnlyChange (InputMethodListener &listener, bool readOnly)
 Notifies the input method that the input method listener read-only state is changed. More...
 
void notifySelectionChange (InputMethodListener &listener, size_t start, size_t end)
 Notifies the input method about changes in text selection in a listener. More...
 
void notifyTextChange (InputMethodListener &listener, string_view text, size_t position)
 Notifies the input method about the text change in a listener passed as argument. More...
 
virtual ~InputMethod ()=default
 Destructor. More...
 

Protected Member Functions

NodeSharedPtr getAttachedNode () const
 Returns the node to which the input method is attached. More...
 
 InputMethod ()=default
 Default constructor. More...
 
Overridables
virtual void connectOverride (string_view text, size_t cursorPosition, size_t selectionStart, size_t selectionEnd)=0
 To store the current state of the active input method listener, override this method. More...
 
virtual void disconnectOverride ()=0
 To clear the state of the input method from previously active input method listener, override this method. More...
 
virtual void notifyTextChangeOverride (string_view text, size_t position)=0
 To handle the text change in an active input method listener, override this method. More...
 
virtual void notifyCompositionStartOverride ()=0
 To handle the start of the text composition on an active input method listener, override this method. More...
 
virtual void notifyCompositionEndOverride ()=0
 To handle the completion or cancellation of the text composition on an active input method listener, override this method. More...
 
virtual void notifyCursorMoveOverride (size_t position)=0
 To handle the cursor position change in an active input method listener, override this method. More...
 
virtual void notifySelectionChangeOverride (size_t start, size_t end)=0
 To handle the changes in text selection in an active input method listener, override this method. More...
 
virtual bool notifyInputTypeAttributesChangeOverride (EchoMode echoMode, InputType inputType)
 To handle the change in the input type of the active input method listener, override this method. More...
 
virtual void notifyReadOnlyChangeOverride (bool readOnly)
 To handle the change in the read-only state of the active input method listener, override this method. More...
 
virtual void notifyEnterKeyPressOverride ()
 Notifies the input method that the active input method listener handles the Enter key press event. More...
 
virtual void notifyEnterKeyReleaseOverride ()
 Notifies the input method that the active input method listener handles the Enter key release event. More...
 
virtual void notifyEnterKeyCancelOverride ()
 Notifies the input method that the active input method listener cancels the Enter key event. More...
 
virtual void notifyEnterKeyLabelChangeOverride (EnterKeyLabel label)
 Notifies the active input method that the label of the Enter key associated with the input method listener changed. More...
 
Input Method Listener notification interface
bool disconnectListener ()
 To disconnect the input method from its active input method listener, call this method. More...
 
void setText (string_view text)
 Tells the active input method listener to replace its cached text with the content passed in the text argument. More...
 
void insertText (size_t position, string_view text)
 Tells the active input method listener to add a text to its cached text. More...
 
void deleteText (size_t start, size_t end)
 Tells the active input method listener to remove the text between the start and end positions. More...
 
void startTextComposition ()
 Tells the active input method listener to enter text composition state at the current cursor position. More...
 
void updateCompositionText (string_view text)
 Tells the active input method listener to update the composition text at a given position. More...
 
void commitCompositionText ()
 Tells the active input method listener to add the composition text received by previous calls of updateCompositionText() into the cached text. More...
 
void cancelTextComposition ()
 Tells the active input method listener to cancel the text composition and discard the composition text. More...
 
void moveCursor (size_t position)
 Tells the active input method listener to update the cursor position. More...
 
void updateSelection (size_t start, size_t end)
 Tells the active input method listener to update the cursor positions at the start and end of the text selection. More...
 
void updateInputType (InputType inputType)
 Tells the active input method listener to update its input type. More...
 
void pressEnterKey ()
 Informs the active input method listener that the Enter key is pressed. More...
 
void releaseEnterKey ()
 Informs the active input method listener that the Enter key is released. More...
 
void cancelEnterKey ()
 Informs the active input method listener that the Enter key event is canceled. More...
 

Detailed Description

The InputMethod class defines the interface of the Kanzi input methods.

You must derive your input method implementations from this interface.

Since
Kanzi 3.9.0

Constructor & Destructor Documentation

virtual kanzi::InputMethod::~InputMethod ( )
virtualdefault

Destructor.

kanzi::InputMethod::InputMethod ( )
explicitprotecteddefault

Default constructor.

Member Function Documentation

void kanzi::InputMethod::connect ( InputMethodListener listener,
Node attachedNode,
string_view  text,
size_t  cursorPosition,
size_t  selectionStart,
size_t  selectionEnd 
)

Connects an input method listener to this input method.

Passes the current state of the input method listener, including text and cursor positions used in the listener.

Parameters
listenerThe input method listener to connect to the input method.
attachedNodeThe Node to which the input method is attached.
textThe text in the listener.
cursorPositionThe position of the cursor.
selectionStartThe position of the start of text selection.
selectionEndThe position of the end of text selection.
void kanzi::InputMethod::disconnect ( InputMethodListener listener)

Disconnects the listener passed as argument.

Parameters
listenerThe input method listener to disconnect.
InputMethodListener* kanzi::InputMethod::getListener ( ) const
inline

Returns the active listener of the input method.

Returns
The active listener of the input method. If the input method has no active listener set, returns nullptr.
bool kanzi::InputMethod::isBlocked ( ) const
inline

Checks whether the input method is blocked by another input method that is in the text composition state.

void kanzi::InputMethod::notifyTextChange ( InputMethodListener listener,
string_view  text,
size_t  position 
)

Notifies the input method about the text change in a listener passed as argument.

Parameters
listenerThe input method listener in which the text changed.
textThe text in the input method listener to update.
positionThe cursor position in the input method listener.
void kanzi::InputMethod::notifyCompositionStart ( InputMethodListener listener)

Notifies the input method that text composition is started on the listener.

Parameters
listenerThe input method listener where text composition is started.
void kanzi::InputMethod::notifyCompositionEnd ( InputMethodListener listener)

Notifies the input method that text composition is completed or canceled on the listener.

Parameters
listenerThe input method listener where text composition is completed or canceled.
void kanzi::InputMethod::notifyCursorMove ( InputMethodListener listener,
size_t  position 
)

Notifies the input method about the cursor position change in a listener.

Parameters
listenerThe input method listener where the cursor position changed.
positionThe cursor position in the input method listener.
void kanzi::InputMethod::notifySelectionChange ( InputMethodListener listener,
size_t  start,
size_t  end 
)

Notifies the input method about changes in text selection in a listener.

If both the start and the end position have the same value, the selection is cleared.

Parameters
listenerThe input method listener where text selection changed.
startThe position of the start of text selection in the input method listener.
endThe position of the end of text selection in the input method listener.
bool kanzi::InputMethod::notifyInputTypeAttributesChange ( InputMethodListener listener,
EchoMode  echoMode,
InputType  inputType 
)

Notifies the input method that the input type attributes of the listener changed.

Parameters
listenerThe input method listener whose input type changed.
echoModeThe echo mode of the input method listener.
inputTypeThe input type of the input method listener.
Returns
If the attributes are updated without the input method changing those, returns true, otherwise false.
void kanzi::InputMethod::notifyReadOnlyChange ( InputMethodListener listener,
bool  readOnly 
)

Notifies the input method that the input method listener read-only state is changed.

Parameters
listenerThe input method listener whose read-only state changed.
readOnlyThe read-only state of the input method listener.
void kanzi::InputMethod::notifyEnterKeyPress ( InputMethodListener listener)

Notifies the input method that the input method listener handles the Enter key press event.

Parameters
listenerThe input method listener that handles the Enter key press event.
void kanzi::InputMethod::notifyEnterKeyRelease ( InputMethodListener listener)

Notifies the input method that the input method listener handles the Enter key release event.

Parameters
listenerThe input method listener that handles the Enter key release event.
void kanzi::InputMethod::notifyEnterKeyCancel ( InputMethodListener listener)

Notifies the input method that the input method listener cancels the Enter key event.

Parameters
listenerThe input method listener that cancels the Enter key event.
void kanzi::InputMethod::notifyEnterKeyLabelChange ( InputMethodListener listener,
EnterKeyLabel  label 
)

Notifies the input method that the label of the Enter key associated with the input method listener changed.

Override this method if the input method supports changing the Enter key label.

Parameters
listenerThe input method listener whose Enter key label changed.
labelThe Enter key label associated to the input method listener.
NodeSharedPtr kanzi::InputMethod::getAttachedNode ( ) const
inlineprotected

Returns the node to which the input method is attached.

Returns
The shared pointer to the node to which the input method is attached.
virtual void kanzi::InputMethod::connectOverride ( string_view  text,
size_t  cursorPosition,
size_t  selectionStart,
size_t  selectionEnd 
)
protectedpure virtual

To store the current state of the active input method listener, override this method.

The state includes text and cursor positions used in the listener.

Parameters
textThe text in the listener.
cursorPositionThe position of the cursor.
selectionStartThe position of the start of text selection.
selectionEndThe position of the end of text selection.
See also
connect()

Implemented in kanzi::WindowsIme.

virtual void kanzi::InputMethod::disconnectOverride ( )
protectedpure virtual

To clear the state of the input method from previously active input method listener, override this method.

Do not call getListener() or getAttachedNode() inside disconnectOverride(). Kanzi can be already destroying the attached node and previously active listener.

See also
disconnect()

Implemented in kanzi::WindowsIme.

virtual void kanzi::InputMethod::notifyTextChangeOverride ( string_view  text,
size_t  position 
)
protectedpure virtual

To handle the text change in an active input method listener, override this method.

Parameters
textThe text in the input method listener to update.
positionThe cursor position in the input method listener.
See also
notifyTextChange()

Implemented in kanzi::WindowsIme.

virtual void kanzi::InputMethod::notifyCompositionStartOverride ( )
protectedpure virtual

To handle the start of the text composition on an active input method listener, override this method.

See also
notifyCompositionStart()

Implemented in kanzi::WindowsIme.

virtual void kanzi::InputMethod::notifyCompositionEndOverride ( )
protectedpure virtual

To handle the completion or cancellation of the text composition on an active input method listener, override this method.

See also
notifyCompositionEnd()

Implemented in kanzi::WindowsIme.

virtual void kanzi::InputMethod::notifyCursorMoveOverride ( size_t  position)
protectedpure virtual

To handle the cursor position change in an active input method listener, override this method.

Parameters
positionThe cursor position in the input method listener.
See also
notifyCursorMove()

Implemented in kanzi::WindowsIme.

virtual void kanzi::InputMethod::notifySelectionChangeOverride ( size_t  start,
size_t  end 
)
protectedpure virtual

To handle the changes in text selection in an active input method listener, override this method.

If both the start and the end position have the same value, Kanzi clears the selection.

Parameters
startThe position of the start of text selection in the input method listener.
endThe position of the end of text selection in the input method listener.
See also
notifySelectionChange()

Implemented in kanzi::WindowsIme.

virtual bool kanzi::InputMethod::notifyInputTypeAttributesChangeOverride ( EchoMode  echoMode,
InputType  inputType 
)
inlineprotectedvirtual

To handle the change in the input type of the active input method listener, override this method.

The implementation must validate the input type and echo mode combination. If the combination is not valid, the implementation must update the input type of the input method listener.

Parameters
echoModeThe echo mode of the input method listener.
inputTypeThe input type of the input method listener.
Returns
If the implementation updates the attributes, returns false, otherwise returns true.
See also
notifyInputTypeAttributesChange()
virtual void kanzi::InputMethod::notifyReadOnlyChangeOverride ( bool  readOnly)
inlineprotectedvirtual

To handle the change in the read-only state of the active input method listener, override this method.

Parameters
readOnlyThe read-only state of the input method listener.
virtual void kanzi::InputMethod::notifyEnterKeyPressOverride ( )
inlineprotectedvirtual

Notifies the input method that the active input method listener handles the Enter key press event.

Reimplemented in kanzi::WindowsIme.

virtual void kanzi::InputMethod::notifyEnterKeyReleaseOverride ( )
inlineprotectedvirtual

Notifies the input method that the active input method listener handles the Enter key release event.

Reimplemented in kanzi::WindowsIme.

virtual void kanzi::InputMethod::notifyEnterKeyCancelOverride ( )
inlineprotectedvirtual

Notifies the input method that the active input method listener cancels the Enter key event.

Reimplemented in kanzi::WindowsIme.

virtual void kanzi::InputMethod::notifyEnterKeyLabelChangeOverride ( EnterKeyLabel  label)
inlineprotectedvirtual

Notifies the active input method that the label of the Enter key associated with the input method listener changed.

Override this method if the input method supports changing the Enter key label.

Parameters
labelThe Enter key label associated to the input method listener.
bool kanzi::InputMethod::disconnectListener ( )
protected

To disconnect the input method from its active input method listener, call this method.

Do not call this method from disconnectOverride().

void kanzi::InputMethod::setText ( string_view  text)
protected

Tells the active input method listener to replace its cached text with the content passed in the text argument.

Parameters
textThe new text to set.
void kanzi::InputMethod::insertText ( size_t  position,
string_view  text 
)
protected

Tells the active input method listener to add a text to its cached text.

Parameters
positionThe position at which to add the text.
textThe text to append to the cached text.
void kanzi::InputMethod::deleteText ( size_t  start,
size_t  end 
)
protected

Tells the active input method listener to remove the text between the start and end positions.

Parameters
startThe start position of the text to remove.
endThe end position of the text to remove.
void kanzi::InputMethod::startTextComposition ( )
protected

Tells the active input method listener to enter text composition state at the current cursor position.

void kanzi::InputMethod::updateCompositionText ( string_view  text)
protected

Tells the active input method listener to update the composition text at a given position.

Parameters
positionThe position where the text is added.
textThe text to append to the cached text.
void kanzi::InputMethod::commitCompositionText ( )
protected

Tells the active input method listener to add the composition text received by previous calls of updateCompositionText() into the cached text.

void kanzi::InputMethod::cancelTextComposition ( )
protected

Tells the active input method listener to cancel the text composition and discard the composition text.

void kanzi::InputMethod::moveCursor ( size_t  position)
protected

Tells the active input method listener to update the cursor position.

Parameters
positionThe position of the cursor to set.
void kanzi::InputMethod::updateSelection ( size_t  start,
size_t  end 
)
protected

Tells the active input method listener to update the cursor positions at the start and end of the text selection.

Parameters
startThe cursor position at the start of the text selection to set.
endThe cursor position at the end of the text selection to set.
void kanzi::InputMethod::updateInputType ( InputType  inputType)
protected

Tells the active input method listener to update its input type.

Parameters
inputTypeThe input type to set.
void kanzi::InputMethod::pressEnterKey ( )
protected

Informs the active input method listener that the Enter key is pressed.

void kanzi::InputMethod::releaseEnterKey ( )
protected

Informs the active input method listener that the Enter key is released.

void kanzi::InputMethod::cancelEnterKey ( )
protected

Informs the active input method listener that the Enter key event is canceled.


The documentation for this class was generated from the following file: