Kanzi 3.9.10
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.
 
void commitCompositionText ()
 Commits the composition text.
 
bool isComposingText () const
 Returns the text composition state of the input method listener.
 
bool isInputMethodAvailable (InputMethod &source) const
 Returns whether the input method is available.
 
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.
 
void onCompositionTextUpdated (InputMethod &source, string_view text)
 The input method source tells the input method listener to update the composition text.
 
void onCursorMoved (InputMethod &source, size_t position)
 The input method source tells the input method listener to update the cursor position.
 
void onExecuteInputMethodAction (InputMethod &source)
 The input method source tells the input method listener to execute the input method action.
 
void onInputMethodAvailable (InputMethod &source, bool available)
 The input method source informs its active input method listener about the available state.
 
bool onInputMethodDisconnected (InputMethod &source)
 The input method source tells its active input method listener that it disconnected itself from the input method listener.
 
void onInputTypeChanged (InputMethod &source, InputType inputType)
 The input method source tells the input method listener to update its input type.
 
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.
 
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.
 
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.
 
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.
 
void onTextCompositionStarted (InputMethod &source)
 The input method source tells the input method listener to enter the text composition state at the current cursor position.
 
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.
 
virtual ~InputMethodListener ()
 Destructor.
 
Input status methods

These methods provide the status of the input to the input methods to which the InputMethodListener is connected.

const TextEditBuffergetText () const
 Returns the text buffer that holds edited UTF-8 content.
 
InputType getInputType () const
 Returns the input type used by the text input methods.
 
InputMethodAction getInputMethodAction () const
 Returns the input method action of the text input methods.
 
bool isReadOnly () const
 Returns whether the text of the TextEditBuffer of an InputMethodListener is unaffected by user input.
 

Protected Member Functions

void connectInputMethods (Node &attachedNode)
 Connects the input methods to this listener.
 
void disconnectInputMethods ()
 Disconnects the input methods from this listener.
 
 InputMethodListener (Domain *domain)
 Constructor.
 
bool isComposingText (InputMethod &inputMethod) const
 Checks whether the inputMethod is in the text composition state.
 
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.
 
Overridable operations
virtual void onInputMethodAvailableOverride (InputMethod &source, bool available)=0
 To receive a notification about the availability of an input method source, override this method.
 
virtual bool onInputMethodDisconnectedOverride (InputMethod &source)=0
 To deactivate an input method listener, implement this method.
 
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.
 
virtual bool onTextChangedOverride (InputMethod &source, string_view text)=0
 To replace the cached text with the text passed as argument, implement this method.
 
virtual bool onTextDeletedOverride (InputMethod &source, size_t start, size_t end)=0
 To delete the characters between the start and the end positions from the cached text, implement this method.
 
virtual bool onTextCompositionStartedOverride (InputMethod &source)=0
 To make the input method listener enter the text composition state, implement this method.
 
virtual bool onCompositionTextUpdatedOverride (InputMethod &source, string_view text)=0
 To update the composition text, implement this method.
 
virtual bool onCompositionTextCommittedOverride (InputMethod &source)=0
 To commit the composition text to the cached text, implement this method.
 
virtual void onTextCompositionCanceledOverride (InputMethod &source)=0
 To cancel text composition, implement this method.
 
virtual bool onCursorMovedOverride (InputMethod &source, size_t position)=0
 To update the cursor position, implement this method.
 
virtual bool onSelectionChangedOverride (InputMethod &source, size_t start, size_t end)=0
 To update the text selection, implement this method.
 
virtual void onInputTypeChangedOverride (InputMethod &source, InputType inputType)=0
 To update the input type, implement this method.
 
virtual void onExecuteInputMethodActionOverride (InputMethod &source)=0
 To execute the input action, implement this method.
 

Protected Attributes

InputMethodWeakPtr m_composingInputMethod
 The input method that provides the text composition.
 
TextEditBuffer m_editBuffer
 The buffer where the text input is stored.
 
InputMethodAction m_inputMethodAction
 The label of the input action.
 
vector< pair< InputMethodSharedPtr, bool > > m_inputMethods
 The input method instances with which the input method listener interacts.
 
InputType m_inputType
 The input type.
 
bool m_isReadOnly
 The read-only state.
 

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

◆ ~InputMethodListener()

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

Destructor.

◆ InputMethodListener()

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

Constructor.

Member Function Documentation

◆ onInputMethodAvailable()

void kanzi::InputMethodListener::onInputMethodAvailable ( InputMethod & source,
bool available )

The input method source informs its active input method listener about the available state.

The input method stays connected also when it is temporarily unavailable.

Parameters
sourceThe input method source that informs its active input method listener about the available state.
availableThe available state of the input method.

◆ isInputMethodAvailable()

bool kanzi::InputMethodListener::isInputMethodAvailable ( InputMethod & source) const

Returns whether the input method is available.

For example, returns whether an on-screen keyboard is visible.

Parameters
sourceThe input method source availability to check.
Returns
If the input method is connected to this input method listener, and it is available, returns true, otherwise returns false.

◆ onInputMethodDisconnected()

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.

◆ onTextChanged()

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.

◆ onTextAdded()

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.

◆ onTextDeleted()

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.

◆ isComposingText() [1/2]

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.

◆ onTextCompositionStarted()

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.

◆ onCompositionTextUpdated()

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.

◆ onCompositionTextCommitted()

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.

◆ onTextCompositionCanceled()

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.

◆ onCursorMoved()

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.

◆ onSelectionChanged()

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.

◆ onInputTypeChanged()

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.

◆ onExecuteInputMethodAction()

void kanzi::InputMethodListener::onExecuteInputMethodAction ( InputMethod & source)

The input method source tells the input method listener to execute the input method action.

Parameters
sourceThe input method source that tells the input method listener to execute the input method action.

◆ cancelTextComposition()

void kanzi::InputMethodListener::cancelTextComposition ( )

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

◆ commitCompositionText()

void kanzi::InputMethodListener::commitCompositionText ( )

Commits the composition text.

◆ getText()

const TextEditBuffer & kanzi::InputMethodListener::getText ( ) const

Returns the text buffer that holds edited UTF-8 content.

Returns
The address of the text buffer.

◆ getInputType()

InputType kanzi::InputMethodListener::getInputType ( ) const

Returns the input type used by the text input methods.

Returns
The input type used by the text input methods.

◆ getInputMethodAction()

InputMethodAction kanzi::InputMethodListener::getInputMethodAction ( ) const

Returns the input method action of the text input methods.

Returns
The input method action of the text input methods.

◆ isReadOnly()

bool kanzi::InputMethodListener::isReadOnly ( ) const

Returns whether the text of the TextEditBuffer of an InputMethodListener is unaffected by user input.

Returns
If the user input does not affect the text of the TextEditBuffer of an InputMethodListener, returns true, otherwise false. Moving the cursor and selecting text is possible also when text editing is disabled.
See also
TextInputManipulator::setReadOnly(), TextInputManipulator::ReadOnlyStateChangedMessage

◆ connectInputMethods()

void kanzi::InputMethodListener::connectInputMethods ( Node & attachedNode)
protected

Connects the input methods to this listener.

◆ disconnectInputMethods()

void kanzi::InputMethodListener::disconnectInputMethods ( )
protected

Disconnects the input methods from this listener.

◆ isComposingText() [2/2]

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

Checks whether the inputMethod is in the text composition state.

◆ onInputMethodAvailableOverride()

virtual void kanzi::InputMethodListener::onInputMethodAvailableOverride ( InputMethod & source,
bool available )
protectedpure virtual

To receive a notification about the availability of an input method source, override this method.

Parameters
sourceThe input method source whose available state changed.
availableThe available state of the input method.

Implemented in kanzi::TextInputManipulator.

◆ onInputMethodDisconnectedOverride()

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.

◆ onTextAddedOverride()

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.

◆ onTextChangedOverride()

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.

◆ onTextDeletedOverride()

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

To delete the characters between the start and the end 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.

◆ onTextCompositionStartedOverride()

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.

◆ onCompositionTextUpdatedOverride()

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.

◆ onCompositionTextCommittedOverride()

virtual bool kanzi::InputMethodListener::onCompositionTextCommittedOverride ( 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.

◆ onTextCompositionCanceledOverride()

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.

◆ onCursorMovedOverride()

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.

◆ onSelectionChangedOverride()

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.

◆ onInputTypeChangedOverride()

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.

◆ onExecuteInputMethodActionOverride()

virtual void kanzi::InputMethodListener::onExecuteInputMethodActionOverride ( InputMethod & source)
protectedpure virtual

To execute the input action, implement this method.

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

Parameters
sourceThe input method that tells the input method listener to execute the input action.

Implemented in kanzi::TextInputManipulator.

◆ updateInputMethods()

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

◆ m_inputMethods

vector<pair<InputMethodSharedPtr, bool> > kanzi::InputMethodListener::m_inputMethods
protected

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

◆ m_composingInputMethod

InputMethodWeakPtr kanzi::InputMethodListener::m_composingInputMethod
protected

The input method that provides the text composition.

◆ m_editBuffer

TextEditBuffer kanzi::InputMethodListener::m_editBuffer
protected

The buffer where the text input is stored.

◆ m_inputMethodAction

InputMethodAction kanzi::InputMethodListener::m_inputMethodAction
protected

The label of the input action.

◆ m_inputType

InputType kanzi::InputMethodListener::m_inputType
protected

The input type.

◆ m_isReadOnly

bool kanzi::InputMethodListener::m_isReadOnly
protected

The read-only state.


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