blackberry nextFocus()

来源:互联网 发布:mac pro 抹掉磁盘 编辑:程序博客网 时间:2024/06/08 06:36

处理焦点
当用户滚动滑轮时,为了指定field 该如何得到焦点,覆写nextFocus()方法。direction 参数
描述了焦点移动的方向(一般来说,当滑轮向下滚动,焦点向下并且向右方向。当滑轮向上
滚动,焦点向上并且向左)。

protected int nextFocus(int direction, boolean alt) {
int index = this.getFieldWithFocusIndex();
if (alt) {
if (direction > 0) {
    // action to perform if trackwheel is rolled up
}
else
{
    // action to perform if trackwheel is rolled down
}
}i
if
(index == this.getFieldWithFocusIndex())
    return super.nextFocus(direction, alt);
else
    return index;
}
为了将焦点转移到下一个field,而以管理器的顺序,这个field 不是下一个field,那么覆写
nextFocus().例如,如果你想为你的管理器实现Page-up 和Page-down 的功能,那么nextFocus()
就有用了。
开发文档里是这样写的,但我在实际中重写nextFocus()后框架根本没有调用,用没有那位对这个有所了解。