public interface KeyboardDelegate
You should implement this interface and register the callbacks with the input method framework by calling the
InputMethodAbility#onCreateKeyboardInterface() method.
SystemCapability.Miscservices#INPUTMETHOD| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
onCursorContextChanged(float x,
float y,
float height) |
Called when the cursor position changes.
|
boolean |
onKeyDown(KeyEvent event) |
Called when a keydown event occurs on the physical keyboard.
|
boolean |
onKeyUp(KeyEvent event) |
Called when a keyup event occurs on the physical keyboard.
|
void |
onSelectionChanged(int oldBegin,
int oldEnd,
int newBegin,
int newEnd) |
Called when the cursor position or the selected text changes.
|
void |
onTextChanged(int token,
EditingText text) |
Called when the text in the component on the client changes in full-screen mode.
|
boolean onKeyDown(KeyEvent event)
This callback is used to respond to an input event of the physical keyboard.
event - Indicates a keydown event of the physical keyboard.true if the input method application consumes the event and terminates event transfer;
returns false if the input method application passes the event to other applications no matter
whether the event is consumed.boolean onKeyUp(KeyEvent event)
This callback is used to respond to an input event of the physical keyboard.
event - Indicates a keyup event of the physical keyboard.true if the input method application consumes the event and terminates event transfer;
returns false if the input method application passes the event to other applications no matter
whether the event is consumed.void onSelectionChanged(int oldBegin,
int oldEnd,
int newBegin,
int newEnd)
This method is usually used in full-screen mode to receive the cursor information changed on the client.
oldBegin - Indicates the start index of the cursor before the selected text changes.oldEnd - Indicates the end index of the cursor before the selected text changes.newBegin - Indicates the start index of the cursor after the selected text changes.newEnd - Indicates the end index of the cursor after the selected text changes.void onCursorContextChanged(float x,
float y,
float height)
This callback is used for physical keyboards. If you want to enable your application to move the candidates window with the cursor, use this callback to obtain the cursor coordinates on the screen and the cursor height.
x - Indicates the horizontal position of the cursor in the screen coordinate system.y - Indicates the position of the cursor bottom in the screen coordinate system.height - Indicates the cursor height. When the cursor locates at the bottom of the screen, you can use this
parameter and y to calculate the position of cursor top and then draw the candidates window above
the cursor.void onTextChanged(int token,
EditingText text)
This method is usually used in full-screen mode to receive text changes on the client.
token - Indicates the ID of the session.text - Indicates the updated text.