需要将什么从键盘应用程序传递给编辑器才能将光标向左移动一个字符?

发布于 2024-09-24 03:55:01 字数 151 浏览 1 评论 0原文

当 Android 编辑器应用程序将被解释为向左箭头时,键盘应用程序期望发送什么键代码?换句话说,如果用户打算将光标向左移动一个字符,键盘程序应该向其调用程序(某种编辑器)发送什么?一个相关问题:“android:codes”属性的负值是什么意思? () 对这些问题的任何指示将不胜感激。

What key code does an Android editor app expect the keyboard app to send when it is going to be interpreted as a left arrow? In other words, what is the keyboard program supposed to send to its calling program (some kind of editor) if the user intends to move the cursor one char to the left? A related issue: what do the minus values for the "android:codes" attribute mean?
() Any pointers to these issues will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰火雁神 2024-10-01 03:55:01

我知道你已经很久没有问这个问题了,但我想我应该捐出我的两分钱。在你的情况下我会尝试的是这样的:

InputConnection ic = getCurrentInputConnection();
String textAbove = ic.getTextBeforeCursor(0x100000, 0).toString();
int cursorPos = textAbove.length();
if (cursorPos>0) ic.setSelection(cursorPos-1, cursorPos-1);

这应该相当不错地模拟左箭头。

I know it's been a long time since you asked this, but I thought I'd throw in my two cents. What I would try in your situation would be this:

InputConnection ic = getCurrentInputConnection();
String textAbove = ic.getTextBeforeCursor(0x100000, 0).toString();
int cursorPos = textAbove.length();
if (cursorPos>0) ic.setSelection(cursorPos-1, cursorPos-1);

That should simulate a left arrow pretty decently.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文