如何覆盖默认OS 6滚动行为 [英] How to override default scrolling behavior in OS 6

查看:100
本文介绍了如何覆盖默认OS 6滚动行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有VerticalFieldManager的自定义扩展,自动滚动本身的数据显示给用户。上面和下面该VFM,有用户可以与之交互的其他组件。在OS5,这个工程完美,正是我的期望。在OS6,与内置的平滑滚动功能,当用户试图从VFM上面的字段下面的字段中滚动时,VFM是由用户的输入转移焦点到VFM下面的字段之前滚动。

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.

请问有什么办法可以覆盖这种行为,并告诉OS不要动我的VFM?在OS5,这是一个简单使得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.

我曾尝试与垂直调节和垂直量化的VFM没有运气摆弄。该VFM实际上从未收到焦点,操作系统只是滚动了。我假设操作系统认为它正在帮助,但它不是! :)

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! :)

推荐答案

我想出了一个解决方案,通过重写 navigationMovement 函数在父管理器中,这样的事情:

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);
}

您将在code以上,我不得不也覆盖从最高层向上滚动时从最底部上下滚动,因为操作系统再次接管和帮助我滚动非的行为看-focusable VFM。

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.

这篇关于如何覆盖默认OS 6滚动行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆