黑莓自定义EditField-处理焦点
黑莓开发让我抓狂。我有一个自定义 EditField
。这是代码:
private EditField m_Txt=new EditField(EditField.FOCUSABLE |
EditField.FILTER_DEFAULT) {
protected void layout(int width, int height)
{
setExtent(Display.getWidth(), m_TxtHeight);
}
public boolean isFocusable()
{
return true;
}
protected void onFocus(int direction)
{
super.onFocus(direction);
invalidate();
}
protected void onUnfocus() {
super.onUnfocus();
invalidate();
}
};
问题是它无法获得焦点。实际上它确实调用了 isFocusable 等,但光标没有显示,我无法写任何东西。由于我是黑莓开发人员,我肯定错过了一些东西,但是什么呢?
多谢
Something is driving me crazy on BlackBerry dev. I have a custom EditField
. Here is the code:
private EditField m_Txt=new EditField(EditField.FOCUSABLE |
EditField.FILTER_DEFAULT) {
protected void layout(int width, int height)
{
setExtent(Display.getWidth(), m_TxtHeight);
}
public boolean isFocusable()
{
return true;
}
protected void onFocus(int direction)
{
super.onFocus(direction);
invalidate();
}
protected void onUnfocus() {
super.onUnfocus();
invalidate();
}
};
The thing is that it cannot get the focus. Actually it does call isFocusable
etc. but the cursor doesn't show and I cannot write anything. I am surely missing something as I'm new to BlackBerry dev, but what ?
Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在使用什么操作系统进行测试?如果是最新的 OS6 版本,我在这些版本中发现了,但您没有在启用选择模式之前,光标不会出现在文本编辑字段中。
What OS are you testing with? If it is a recent OS6 release, I've found in those versions you don't get a cursor in text edit fields until you enable select mode.
我其实已经找到答案了。我完全忘记调用 super.layout 方法。所以布局方法应该是:
I've actually found the answer. I totally forgot to call the super.layout method. So the layout method should be: