Kanzi Engine API
kanzi::InputMethodListener Class Referenceabstract

The InputMethodListener defines the communication interface of Kanzi input methods. More...

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

Inheritance diagram for kanzi::InputMethodListener:
[legend]

Public Member Functions

void cancelTextComposition ()
 Tells the input method, which provides the text composition, to cancel the text composition. More...
 
void commitCompositionText ()
 Commits the composition text. More...
 
bool isComposingText () const
 Returns the text composition state of the input method listener. More...
 
void onCompositionTextCommitted (InputMethod &source)
 The input method source tells the input method listener to add the composition text received by previous calls of onCompositionTextUpdated() into the cached text. More...
 
void onCompositionTextUpdated (InputMethod &source, string_view text)
 The input method source tells the input method listener to update the composition text. More...
 
void onCursorMoved (InputMethod &source, size_t position)
 The input method source tells the input method listener to update the cursor position. More...
 
void onEnterKeyCanceled (InputMethod &source)
 The input method source informs the input method listener that the Enter key event is canceled. More...
 
void onEnterKeyPressed (InputMethod &source)
 The input method source informs the input method listener that the Enter key is pressed. More...
 
void onEnterKeyReleased (InputMethod &source)
 The input method source informs the input method listener that the Enter key is released. More...
 
bool onInputMethodDisconnected (InputMethod &source)
 The input method source tells its active input method listener that it disconnected itself from the input method listener. More...
 
void onInputTypeChanged (InputMethod &source, InputType inputType)
 The input method source tells the input method listener to update its input type. More...
 
void onSelectionChanged (InputMethod &source, size_t start, size_t end)
 The input method source tells the input method listener to update the cursor positions at the start and end of the text selection. More...
 
void onTextAdded (InputMethod &source, size_t position, string_view text)
 The input method source tells the input method listener to add a text to its cached text. More...
 
void onTextChanged (InputMethod &source, string_view text)
 The input method source tells the input method listener to replace its cached text with the content passed in the text argument. More...
 
void onTextCompositionCanceled (InputMethod &source)
 The input method source tells the input method listener to cancel the text composition, and remove the composition text from the content. More...
 
void onTextCompositionStarted (InputMethod &source)
 The input method source tells the input method listener to enter the text composition state at the current cursor position. More...
 
void onTextDeleted (InputMethod &source, size_t start, size_t end)
 The input method source tells the input method listener to remove the text between the start and end positions. More...
 
virtual ~InputMethodListener ()
 Destructor. More...
 

Protected Member Functions

void connectInputMethods (Node &attachedNode, bool readOnly)
 Connects the input methods to this listener. More...
 
void disconnectInputMethods ()
 Disconnects the input methods from this listener. More...
 
 InputMethodListener (Domain *domain)
 Constructor. More...
 
bool isComposingText (InputMethod &inputMethod) const
 Checks whether the inputMethod is in the text composition state. More...
 
template<typename Method , typename... Arguments>
void updateInputMethods (InputMethod *excludeInputMethod, Method method, const Arguments &...arguments)
 Calls a method of each input method with the arguments passed. More...
 
Overridable operations
virtual bool onInputMethodDisconnectedOverride (InputMethod &source)=0
 To deactivate an input method listener, implement this method. More...
 
virtual bool onTextAddedOverride (InputMethod &source, size_t position, string_view text)=0
 To add text at a given position in the cached text, implement this method. More...
 
virtual bool onTextChangedOverride (InputMethod &source, string_view text)=0
 To replace the cached text with the text passed as argument, implement this method. More...
 
virtual bool onTextDeletedOverride (InputMethod &source, size_t start, size_t end)=0
 To delete the characters between the begin and positions from the cached text, implement this method. More...
 
virtual bool onTextCompositionStartedOverride (InputMethod &source)=0
 To make the input method listener enter the text composition state, implement this method. More...
 
virtual bool onCompositionTextUpdatedOverride (InputMethod &source, string_view text)=0
 To update the composition text, implement this method. More...
 
virtual bool onCompositionTextCommitedOverride (InputMethod &source)=0
 To commit the composition text to the cached text, implement this method. More...
 
virtual void onTextCompositionCanceledOverride (InputMethod &source)=0
 To cancel text composition, implement this method. More...
 
virtual bool onCursorMovedOverride (InputMethod &source, size_t position)=0
 To update the cursor position, implement this method. More...
 
virtual bool onSelectionChangedOverride (InputMethod &source, size_t start, size_t end)=0
 To update the text selection, implement this method. More...
 
virtual void onInputTypeChangedOverride (InputMethod &source, InputType inputType)=0
 To update the input type, implement this method. More...
 
virtual void onEnterKeyPressedOverride (InputMethod &source)=0
 To handle the Enter key press, implement this method. More...
 
virtual void onEnterKeyReleasedOverride (InputMethod &source)=0
 To handle the Enter key release, implement this method. More...
 
virtual void onEnterKeyCanceledOverride (InputMethod &source)=0
 To handle the Enter key cancel, implement this method. More...
 

Protected Attributes

InputMethodWeakPtr m_composingInputMethod
 The input method that provides the text composition. More...
 
TextEditBuffer m_editBuffer
 The buffer where the text input is stored. More...
 
EnterKeyLabel m_enterKeyLabel
 The Enter key action. More...
 
vector< InputMethodSharedPtrm_inputMethods
 The input method instances with which the input method listener interacts. More...
 
InputType m_inputType
 The input type. More...
 

Detailed Description

The InputMethodListener defines the communication interface of Kanzi input methods.

Input methods use this interface to update the active client about the changes occurring on the input method. The input method listener implementation must use the InputMethod interface to initiate updates, and to notify the input methods about changes that occur on the client side.

Since
Kanzi 3.9.0

Constructor & Destructor Documentation

virtual kanzi::InputMethodListener::~InputMethodListener ( )
virtual

Destructor.

kanzi::InputMethodListener::InputMethodListener ( Domain domain)
explicitprotected

Constructor.

Member Function Documentation

bool kanzi::InputMethodListener::onInputMethodDisconnected ( InputMethod source)

The input method source tells its active input method listener that it disconnected itself from the input method listener.

Parameters
sourceThe input method source that tells its active input method listener that it disconnected.
Returns
If the input method source successfully notifies its active input method listener that it disconnected, returns true, otherwise false.
void kanzi::InputMethodListener::onTextChanged ( InputMethod source,
string_view  text 
)

The input method source tells the input method listener to replace its cached text with the content passed in the text argument.

Parameters
sourceThe input method source that tells the input method listener to replace the cached text.
textThe new text to set.
void kanzi::InputMethodListener::onTextAdded ( InputMethod source,
size_t  position,
string_view  text 
)

The input method source tells the input method listener to add a text to its cached text.

Parameters
sourceThe input method source that tells the input method listener to add a text to the cached text.
positionThe position where the text is added.
textThe text to append to the cached text.
void kanzi::InputMethodListener::onTextDeleted ( InputMethod source,
size_t  start,
size_t  end 
)

The input method source tells the input method listener to remove the text between the start and end positions.

Parameters
sourceThe input method source that tells the input method listener to remove the text.
startThe start position of the text to remove.
endThe end position of the text to remove.
bool kanzi::InputMethodListener::isComposingText ( ) const

Returns the text composition state of the input method listener.

Returns
If the input method listener has an input method backend which is in the text composition state, true, otherwise false.
void kanzi::InputMethodListener::onTextCompositionStarted ( InputMethod source)

The input method source tells the input method listener to enter the text composition state at the current cursor position.

Parameters
sourceThe input method source that tells the input method listener to prepare for receiving composition text.
void kanzi::InputMethodListener::onCompositionTextUpdated ( InputMethod source,
string_view  text 
)

The input method source tells the input method listener to update the composition text.

Parameters
sourceThe input method source that tells the input method listener to update the composition text.
textThe text to insert into the cached text.
void kanzi::InputMethodListener::onCompositionTextCommitted ( InputMethod source)

The input method source tells the input method listener to add the composition text received by previous calls of onCompositionTextUpdated() into the cached text.

Parameters
sourceThe input method source that tells the input method listener to commit the composition text.
void kanzi::InputMethodListener::onTextCompositionCanceled ( InputMethod source)

The input method source tells the input method listener to cancel the text composition, and remove the composition text from the content.

Parameters
sourceThe input method source that tells the input method listener to cancel the text composition.
void kanzi::InputMethodListener::onCursorMoved ( InputMethod source,
size_t  position 
)

The input method source tells the input method listener to update the cursor position.

Parameters
sourceThe input method source that tells the input method listener to update the cursor position.
positionThe position of the cursor to set.
void kanzi::InputMethodListener::onSelectionChanged ( InputMethod source,
size_t  start,
size_t  end 
)

The input method source tells the input method listener to update the cursor positions at the start and end of the text selection.

Parameters
sourceThe input method that tells the input method listener to update the cursor positions.
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::InputMethodListener::onInputTypeChanged ( InputMethod source,
InputType  inputType 
)

The input method source tells the input method listener to update its input type.

Parameters
sourceThe input method source that tells the input method listener to update its input type.
inputTypeThe input type to set.
void kanzi::InputMethodListener::onEnterKeyPressed ( InputMethod source)

The input method source informs the input method listener that the Enter key is pressed.

Parameters
sourceThe input method source that tells the input method listener that the Enter key is pressed.
void kanzi::InputMethodListener::onEnterKeyReleased ( InputMethod source)

The input method source informs the input method listener that the Enter key is released.

Parameters
sourceThe input method source that tells the input method listener that the Enter key is released.
void kanzi::InputMethodListener::onEnterKeyCanceled ( InputMethod source)

The input method source informs the input method listener that the Enter key event is canceled.

Parameters
sourceThe input method source that tells the input method listener that the Enter key event is canceled.
void kanzi::InputMethodListener::cancelTextComposition ( )

Tells the input method, which provides the text composition, to cancel the text composition.

void kanzi::InputMethodListener::commitCompositionText ( )

Commits the composition text.

void kanzi::InputMethodListener::connectInputMethods ( Node attachedNode,
bool  readOnly 
)
protected

Connects the input methods to this listener.

void kanzi::InputMethodListener::disconnectInputMethods ( )
protected

Disconnects the input methods from this listener.

bool kanzi::InputMethodListener::isComposingText ( InputMethod inputMethod) const
protected

Checks whether the inputMethod is in the text composition state.

virtual bool kanzi::InputMethodListener::onInputMethodDisconnectedOverride ( InputMethod source)
protectedpure virtual

To deactivate an input method listener, implement this method.

Parameters
sourceThe input method source that tells the input method listener to deactivate.
Returns
If the input method listener successfully deactivates, returns true, otherwise false.

Implemented in kanzi::TextInputManipulator.

virtual bool kanzi::InputMethodListener::onTextAddedOverride ( InputMethod source,
size_t  position,
string_view  text 
)
protectedpure virtual

To add text at a given position in the cached text, implement this method.

This method is called by the InputMethodListener::onTextAdded() method.

Parameters
sourceThe input method source that tells the input method listener to add a text to the cached text.
positionThe position where to add the text.
textThe text to append to the cached text. Kanzi expects the input method listener to move the cursor to the end of the text added to the cached text.
Returns
If the operation succeeds, returns true, otherwise false.

Implemented in kanzi::TextInputManipulator.

virtual bool kanzi::InputMethodListener::onTextChangedOverride ( InputMethod source,
string_view  text 
)
protectedpure virtual

To replace the cached text with the text passed as argument, implement this method.

This method is called by the InputMethodListener::onTextChanged() method.

Parameters
sourceThe input method source that tells the input method listener to replace the cached text.
textThe text to set.
Returns
If the operation succeeds, returns true, otherwise false.

Implemented in kanzi::TextInputManipulator.

virtual bool kanzi::InputMethodListener::onTextDeletedOverride ( InputMethod source,
size_t  start,
size_t  end 
)
protectedpure virtual

To delete the characters between the begin and positions from the cached text, implement this method.

This method is called by the InputMethodListener::onTextDeleted() method.

Parameters
sourceThe input method source that tells the input method listener to remove the text.
startThe start position of the text to remove.
endThe end position of the text to remove.
Returns
If the operation succeeds, returns true, otherwise false.

Implemented in kanzi::TextInputManipulator.

virtual bool kanzi::InputMethodListener::onTextCompositionStartedOverride ( InputMethod source)
protectedpure virtual

To make the input method listener enter the text composition state, implement this method.

This method is called by the InputMethodListener::onTextCompositionStarted() method.

Parameters
sourceThe input method source that tells the input method listener to enter the text composition state.
Returns
If the input method listener enters the text composition state, returns true, otherwise false.

Implemented in kanzi::TextInputManipulator.

virtual bool kanzi::InputMethodListener::onCompositionTextUpdatedOverride ( InputMethod source,
string_view  text 
)
protectedpure virtual

To update the composition text, implement this method.

This method is called by the InputMethodListener::onCompositionTextUpdated() method.

Parameters
sourceThe input method source that tells the input method listener to update the composition text.
textThe text to insert into the cached text.
Returns
If the operation succeeds, returns true, otherwise false.

Implemented in kanzi::TextInputManipulator.

virtual bool kanzi::InputMethodListener::onCompositionTextCommitedOverride ( InputMethod source)
protectedpure virtual

To commit the composition text to the cached text, implement this method.

This method is called by the InputMethodListener::onCompositionTextCommitted() method.

Parameters
sourceThe input method source that tells the input method listener to commit the composition text.
Returns
If the operation succeeds, returns true, otherwise false.

Implemented in kanzi::TextInputManipulator.

virtual void kanzi::InputMethodListener::onTextCompositionCanceledOverride ( InputMethod source)
protectedpure virtual

To cancel text composition, implement this method.

This method is called by the InputMethodListener::onTextCompositionCanceled() method.

Parameters
sourceThe input method source that tells the input method listener to cancel text composition.

Implemented in kanzi::TextInputManipulator.

virtual bool kanzi::InputMethodListener::onCursorMovedOverride ( InputMethod source,
size_t  position 
)
protectedpure virtual

To update the cursor position, implement this method.

This method is called by the InputMethodListener::onCursorMoved() method.

Parameters
sourceThe input method source that tells the input method listener to update the cursor position.
positionThe position of the cursor to set.
Returns
If the operation succeeds, returns true, otherwise false.

Implemented in kanzi::TextInputManipulator.

virtual bool kanzi::InputMethodListener::onSelectionChangedOverride ( InputMethod source,
size_t  start,
size_t  end 
)
protectedpure virtual

To update the text selection, implement this method.

This method is called by the InputMethodListener::onSelectionChanged() method.

Parameters
sourceThe input method that tells the input method listener to update the cursor positions.
startThe cursor position at the start of the text selection to set.
endThe cursor position at the end of the text selection to set.
Returns
If the operation succeeds, returns true, otherwise false.

Implemented in kanzi::TextInputManipulator.

virtual void kanzi::InputMethodListener::onInputTypeChangedOverride ( InputMethod source,
InputType  inputType 
)
protectedpure virtual

To update the input type, implement this method.

This method is called by the InputMethodListener::onInputTypeChanged() method.

Parameters
sourceThe input method that tells the input method listener to update the input type.
inputTypeThe input type to set.

Implemented in kanzi::TextInputManipulator.

virtual void kanzi::InputMethodListener::onEnterKeyPressedOverride ( InputMethod source)
protectedpure virtual

To handle the Enter key press, implement this method.

This method is called by the InputMethodListener::onEnterKeyPressed() method.

Parameters
sourceThe input method that tells the input method listener that the Enter key is pressed.

Implemented in kanzi::TextInputManipulator.

virtual void kanzi::InputMethodListener::onEnterKeyReleasedOverride ( InputMethod source)
protectedpure virtual

To handle the Enter key release, implement this method.

This method is called by the InputMethodListener::onEnterKeyReleased() method.

Parameters
sourceThe input method that tells the input method listener that the Enter key is released.

Implemented in kanzi::TextInputManipulator.

virtual void kanzi::InputMethodListener::onEnterKeyCanceledOverride ( InputMethod source)
protectedpure virtual

To handle the Enter key cancel, implement this method.

This method is called by the InputMethodListener::onEnterKeyCanceled() method.

Parameters
sourceThe input method that tells the input method listener that the Enter key event is canceled.

Implemented in kanzi::TextInputManipulator.

template<typename Method , typename... Arguments>
void kanzi::InputMethodListener::updateInputMethods ( InputMethod excludeInputMethod,
Method  method,
const Arguments &...  arguments 
)
inlineprotected

Calls a method of each input method with the arguments passed.

Template Parameters
MethodThe method type.
ArgumentsThe argument types.
Parameters
excludeInputMethodThe input method to exclude. The method is not called on this input method.
methodThe address of the method to call.
argumentsThe arguments to pass to the method.

Member Data Documentation

vector<InputMethodSharedPtr> kanzi::InputMethodListener::m_inputMethods
protected

The input method instances with which the input method listener interacts.

InputMethodWeakPtr kanzi::InputMethodListener::m_composingInputMethod
protected

The input method that provides the text composition.

TextEditBuffer kanzi::InputMethodListener::m_editBuffer
protected

The buffer where the text input is stored.

EnterKeyLabel kanzi::InputMethodListener::m_enterKeyLabel
protected

The Enter key action.

InputType kanzi::InputMethodListener::m_inputType
protected

The input type.


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