I have a custom extension of VerticalFieldManager that automatically scrolls itself to display data to the user. Both above and below that VFM, there are other components that the user can interact with. On OS5, this works perfectly and exactly how I expect. On OS6, with the built-in "smooth scrolling" feature, when the user tries to scroll from the fields above the VFM to the fields below, the VFM is scrolled by the user's input before transferring focus to the fields below 开发者_运维百科the VFM.
Is there any way to override this behavior and tell the OS to leave my VFM alone? In OS5, this was a simple as making the VFM non-focusable.
I have tried fiddling with the vertical adjustment and vertical quantization on the VFM with no luck. The VFM never actually receives focus, the OS just scrolls it. I assume the OS thinks that it is being helpful, but it is not! :)
You could possibly mess with nextFocus()
in the parent Manager to just skip the middle VFM. Maybe also override onFocus()
for the middle on to just go to the next. I know that it should be doing this by setting it non-focusable, but maybe override isFocusable()
to return false.
I figured out a solution by overriding the navigationMovement
function in the parent Manager, something like this:
protected boolean navigationMovement(int dx, int dy, int status, int time) {
if (getField(getFieldWithFocusIndex()) == tabbar) {
Field f = tabbar.getFieldWithFocus();
if (f == lastTabButton) {
if (dy > 0) {
tabData.setFocus();
return true;
}
} else if (f == firstTabButton) {
if (dy < 0) {
return true;
}
}
} else if (getField(getFieldWithFocusIndex()) == tabData) {
MyTab tab = (MyTab) tabs.get(tabData);
if (tab != null && !tab.willHandleNavigationMovement(dx, dy)) {
if (dy != 0) {
if (dy < 0)
lastTabButton.setFocus();
return true;
}
}
}
return super.navigationMovement(dx, dy, status, time);
}
You will see in the code above that I had to also override the behavior when scrolling up from the very top and scrolling down from the very bottom because the OS was again taking over and "helping" me scroll the non-focusable VFM.
精彩评论