typedef struct InputMethod_CursorInfo InputMethod_CursorInfo
InputMethod_CursorInfo is an opaque type for cursor information. It describes the position and size of the cursor on the physical screen during text input, including the horizontal coordinate (left), vertical coordinate (top), width (width), and height (height) of the cursor.
Purpose: Supplies the input method service with precise position and size information of the cursor. The input method relies on this information to implement the following features:
Cursor tracking: The keyboard panel adjusts its display position based on the cursor position to avoid obscuring the region where the cursor resides.
Candidate word positioning: The input method displays the candidate word region near the cursor to deliver an accurate input experience.
Region avoidance calculation: The input method calculates the region to be avoided according to the cursor height and position.
Usage scenarios:
Carrying cursor information in TextConfig: When the app returns TextConfig in the OH_TextEditorProxy_GetTextConfigFunc callback, the CursorInfo contained in it informs the input method of the current cursor position and size.
Active notification of cursor updates: When the cursor position changes (for example, the user moves the cursor or text insertion shifts the cursor), the app actively notifies the input method of the latest cursor position via OH_InputMethodProxy_NotifyCursorUpdate.
Related functions
| Function | Description |
|---|---|
| OH_CursorInfo_Create | Creates a CursorInfo instance. The values of left, top, width, and height need to be passed in. |
| OH_CursorInfo_Destroy | Destroys a CursorInfo instance. |
| OH_CursorInfo_SetRect | Sets the position and size of the cursor. |
| OH_CursorInfo_GetRect | Obtains the position and size of the cursor. |
Relationship with other structs:
Relationship with InputMethod_TextConfig: CursorInfo is a sub-property of TextConfig. When the app returns TextConfig in the OH_TextEditorProxy_GetTextConfigFunc callback, TextConfig contains CursorInfo. The input method obtains cursor information via OH_TextConfig_GetCursorInfo. Therefore, you need to first create a CursorInfo instance and set valid cursor coordinates, and then assign the CursorInfo to TextConfig within the GetTextConfig callback.
Relationship with OH_InputMethodProxy_NotifyCursorUpdate: CursorInfo is passed directly as a parameter of NotifyCursorUpdate to actively notify the input method of cursor position changes. After CursorInfo is created and updated, the app sends the latest cursor information to the input method through NotifyCursorUpdate.
Relationship with InputMethod_InputMethodProxy: The NotifyCursorUpdate function requires both InputMethod_InputMethodProxy (returned by the attach function) and InputMethod_CursorInfo. inputMethodProxy identifies the interaction channel while cursorInfo carries cursor data.
Since: 12
Related module: InputMethod
Header file: inputmethod_cursor_info_capi.h