开发者

Consuming all touchEvents not preventing scrolling on the blackberry storm

开发者 https://www.devze.com 2022-12-29 06:59 出处:网络
I am trying to make a custom control for the BlackBerry Storm using SDK v5.0. This control needs to disable scrolling while the user is dragging elements within a field. The problem is that even if I

I am trying to make a custom control for the BlackBerry Storm using SDK v5.0. This control needs to disable scrolling while the user is dragging elements within a field. The problem is that even if I my control consumes every single touch event send to it, when the user lifts their finger off the screen it still flings up or down as if its finishing 开发者_C百科a scroll action.

Does anyone know of a way to prevent this from happening or what I might be doing wrong ?

Thank you.


I guess I should have posted this earlier.

There seems to be a bug in the MainScreen class which prevents setScrollingInertial(false) from having any effect. To get around this issue and solve the problem I did the folloing:

public static void main(String[] args)
{
    MainScreen ms = new MainScreen(NO_HORIZONTAL_SCROLL | NO_VERTICAL_SCROLL);
    VerticalFieldManager vfm = VerticalFieldManager()
    {
        public VerticalFieldManager()
        {           
            super(HORIZONTAL_SCROLL | VERTICAL_SCROLL); 
            setScrollingInertial(true);
        }       

        protected boolean touchEvent(TouchEvent message) 
        {                               
            int code = message.getEvent();          
            boolean result = super.touchEvent(message); 
            if(code == TouchEvent.DOWN) 
            {
                setScrollingInertial(!result);
            }
            return result;
        }
    };
    ms.add(vfm);
}


I have had problem with moving the finger off the screen and I can't say I found a solution for that. On the other hand, have you tried changing the scrolling property of the manager or the screen (or the screen itself) with NO_SCROLL?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号