Blackberry Storm Emulator - TouchGesture events not firing, how to get a Swipe to work?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 14:00:04

问题


Been playing with the Storm Emulator and the 4.7 JDE, for the life of me I can't figure out how to fire gesture events in the emulator.

Below is the touch event code for the RIM sample app EmbeddedMapDemo. It seems straightforward enough, but touchGesture.getEvent() == TouchGesture.SWIPE never seems to register to true.

How can I register swipes in the Emulator? With my mouse I try doing left-click and drag but that does not seem to work.

/**
* @see Field#touchEvent(TouchEvent)
*/
protected boolean touchEvent(TouchEvent message)
{        
    boolean isConsumed = false;

    if(_mapField.isClicked())
    {
        TouchGesture touchGesture = message.getGesture(); 
        if (touchGesture != null)
        {                
            // If the user has performed a swipe gesture we will 
            // move the map accordingly.
            if (touchGesture.getEvent() == TouchGesture.SWIPE)
            {      
                // Retrieve the swipe magnitude so we know how
                // far to move the map.
                int magnitude = touchGesture.getSwipeMagnitude();

                // Move the map in the direction of the swipe.
                switch(touchGesture.getSwipeDirection())
                {
                    case TouchGesture.SWIPE_NORTH:
                        _mapField.move(0, - magnitude);
                        break;
                    case TouchGesture.SWIPE_SOUTH:
                        _mapField.move(0, magnitude);
                        break;
                    case TouchGesture.SWIPE_EAST:
                        _mapField.move(- magnitude, 0);
                        break;
                    case TouchGesture.SWIPE_WEST:
                        _mapField.move(magnitude, 0);
                        break;                            
                } 
                // We've consumed the touch event.
                isConsumed = true; 
            }
        }     
    }
    return isConsumed;       
}

回答1:


Pressing the left mouse button simulates clicking down the screen... the simulator (and also an actual Storm device, I think) won't fire TouchGesture events while you're clicking down on the screen.

What you want to do is hold down the right mouse button and drag, since the right mouse button simulates a screen tap, without click. This way, you should be able to get TouchGestures to fire.

It's a little hard to do a gesture on the simulator, you kinda have to move fast, but if you use the right mouse button you should be able to do it.



来源:https://stackoverflow.com/questions/1173044/blackberry-storm-emulator-touchgesture-events-not-firing-how-to-get-a-swipe-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!