I use a custome field. the field height is larger than the screen height.
I override the navigationMovement and getFocusRect method to implement the focus movement inside the field. now i have a problem, when the focus rect is outside the view, the screen do not scroll, so how to implement this behave. just like the RichTextField , when the focus rect is outside the view, the screen will scroll to display the next focus rect.
any help? thanks!
Code:
public void getFocusRect(XYRect rect) {
rect.set(0, verticalPadding+headerHeight+rowHeight*selectedRowIndex, getWidth(), rowHeight);
}
protected boolean navigationMovement(int dx, int dy, int status, int time) {
if ((status&KeypadListener.STATUS_FOUR_WAY) == KeypadListener.STATUS_FOUR_WAY) {
if (dx > 0) {
xoffset -= 10;
invalidate();
return true;
} else if (dx < 0) {
xoffset += 10;
invalidate();
if(xoffset > 0) {
xoffset = 0;
return true;
}
} else if (dy > 0) {
if(selectedRowIndex < this.rowNum) {
selectedRowIndex ++;
if(selectedRowIndex == rowNum) {
selectedRowIndex = rowNum-1;
return false;
}
invalidate();
return true;
}
} else if (dy < 0) {
if(selectedRowIndex > 0) {
selectedRowIndex --;
if(selectedRowIndex < 0) {
selectedRowIndex = 0;
return false;
}
invalidate();
return true;
}
}
}
return super.navigationMovement(dx, dy, status, time);
}