挂钩 EditField 设置为 FILTER_REAL_NUMERIC 的删除键

发布于 2024-11-01 06:11:05 字数 473 浏览 1 评论 0原文

我试图让删除键像典型的退格键一样删除字符。 MyEditField 是 EditField 的子类,常用的 EditField 包含三个方法,protected int backspace( int count, int context )public int backspace( int count ) 和 <代码>受保护的布尔退格键()。

MyEditField 在实例化时设置为 FILTER_REAL_NUMERIC,并且我已尝试使用上述所有方法来使删除键起作用。是否需要重写退格函数才能工作,或者我是否必须编写自定义算法来获取删除键以删除字符串末尾的字符?

我已阅读文档,但找不到任何提及退格功能何时起作用以及何时不起作用的内容。另外,我知道系统(又名模拟器)正在注册删除按键,因为我可以将按键代码打印到控制台。

我正在尝试得到一些比必须通过 BB 菜单来清除整个字段更用户友好的东西。

I am trying to get the delete key remove characters like a typical backspace key. MyEditField is a subclass of EditField, and the stock EditField contains three methods, protected int backspace( int count, int context ), public int backspace( int count ), and protected boolean backspace().

MyEditField is set to FILTER_REAL_NUMERIC when instantiated, and I have tried using all the above methods to get the delete key to work. Is it necessary to override the backspace functions to get to work, or am I going to have to write a custom algorithm to get the delete key to remove a character at the end of the string?

I have read the documentation, and I could not find any mention of when the backspace functions will work and when they will not. Also, I know the system (a.k.a. simulator) is registering a key press on the delete since I can print the key code to the console.

I am trying get something more user friendly than having to go through the BB menu to clear the entire field.

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

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

发布评论

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

评论(1

阳光下的泡沫是彩色的 2024-11-08 06:11:05

是否需要重写退格函数才能开始工作

不,不需要。只需捕获按键事件并调用 backspace() 即可。有点像:

protected boolean keyChar(char key, int status, int time) {
    if (key == Characters.DELETE) {
        backspace();
        return true;
    }
    return super.keyChar(key, status, time);
}

Is it necessary to override the backspace functions to get to work

No, it isn't. Just catch the key event and call backspace(). Smth like:

protected boolean keyChar(char key, int status, int time) {
    if (key == Characters.DELETE) {
        backspace();
        return true;
    }
    return super.keyChar(key, status, time);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文