I have a custom object list field with implemented scrolling routine.
public int moveFocus(int amount, int status, int time) {
invalidate(getSelectedIndex());
int unused = super.moveFocus(amount, status, time);
return Math.abs(unused) + 1;
}
public boolean navigationMovement(int dx, int dy, int status, int time) {
if (dy > 0) {
if (selectedIndex < getSize() - 1) {
setSelectedIndex(selectedIndex + 1);
}
} else if (dy < 0) {
if (selectedIndex > 0) {
setSelectedIndex(selectedIndex - 1);
}
}
return true;
}
Scrolling works fine when I scroll with trackwheel, but gets broken when app is launched on a device with trackball. I figured out that problem lays in framework method moveFocus which is not called at all when I scroll with trackball.
Issue has been resolved by changing
return true;
toreturn false;
innavigationMovement
method. This makes a good example of a buggy api design. When you see some gui event handling method like this returning boolean your first and only suggestion is that the return value means the event has been consumed. But in case ofnavigationMovement
method you're wrong. Here's an extract from JDE 4.2.1 javadocBravo RIM!