输入法如何请求'updateCursor'事件?

uaa*_*ius 5 android android-input-method

我们正在实现自定义输入法服务,并且我们有兴趣接收游标更新事件。InputMethodSession的updateCursor()的文档说:“ 当目标输入字段的光标位置在其窗口内更改时,将调用此方法。通常不调用此方法,但仅在输入方法要求时才报告。

输入法如何请求此事件?

提前致谢,

安德里

mhs*_*ith 4

看来这还没有实现。在实现中TextView,调用updateCursor是以 为条件的InputMethodManager.isWatchingCursor,它的定义如下:

/**
 * Returns true if the current input method wants to watch the location
 * of the input editor's cursor in its window.
 */
public boolean isWatchingCursor(View view) {
    return false;
}
Run Code Online (Sandbox Code Playgroud)

幸运的是,您可以使用 检测光标移动onUpdateSelection,尽管它们将作为文本中的逻辑位置而不是矩形提供给您。