一直与风暴模拟器和4.7 JDE玩,对我的生活我无法弄清楚如何激发手势事件在模拟器。

以下是在RIM示例应用EmbeddedMapDemo触摸事件代码。这似乎简单的足够了,但touchGesture.getEvent()== TouchGesture.SWIPE似乎从未注册为true。

我如何注册在模拟器上挥笔?随着我的鼠标我尝试做单击鼠标左键并拖动,但似乎并没有工作。

/**
* @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;       
}
有帮助吗?

解决方案

按下鼠标左键点击摸拟按住屏幕...模拟器(还有一个实际的风暴设备,我认为),当你点击屏幕上向下将不会触发TouchGesture事件。

您想要做的是按住的鼠标右键的和阻力,因为鼠标右键模拟屏幕点击,如果没有点击。这样一来,你应该能够得到TouchGestures火。

这一点很难做到在模拟器上的手势,你还挺必须迅速采取行动,但如果你使用鼠标右键,你应该能够做到这一点。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top