Blackberry Storm Emulator - TouchGesture 事件未触发,如何让 Swipe 工作?

标签 blackberry touch blackberry-storm gesture-recognition swipe

一直在玩 Storm 模拟器和 4.7 JDE,我一直想不出如何在模拟器中触发手势事件。

下面是 RIM 示例应用程序 EmbeddedMapDemo 的触摸事件代码。看起来很简单,但 touchGesture.getEvent() == TouchGesture.SWIPE 似乎从未注册为真。

如何在模拟器中注册滑动?我尝试使用鼠标左键单击并拖动,但这似乎不起作用。

/**
* @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;       
}

最佳答案

按下鼠标左键模拟点击屏幕...模拟器(我认为也是一个实际的 Storm 设备)不会在您点击屏幕时触发 TouchGesture 事件。

您要做的是按住鼠标右键并拖动,因为鼠标右键模拟屏幕点击,而不是点击。这样,您应该能够触发 TouchGestures。

在模拟器上做手势有点困难,你必须快速移动,但如果你使用鼠标右键,你应该可以做到。

关于Blackberry Storm Emulator - TouchGesture 事件未触发,如何让 Swipe 工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1173044/

相关文章:

java - 在黑莓中检测触摸屏?

iphone - 触摸内部拖动会反复触发声音,并且内部触摸不起作用

javascript - Chrome 开发者工具如何模拟触摸事件?

java - 使用 Java 在运行时识别 BlackBerry 设备

user-interface - 如何在 Blackberry Storm 中设置抗锯齿?

Java 服务器无法使用 Blackberry 的 AESkey 加密/解密数据

blackberry - PhoneGap 应用程序黑莓(服务器端)中的推送通知

javascript - 获取多个 touchend 事件 javascript

java - 黑莓:触摸时屏幕不滚动

java - 如何为黑莓手机制作注销菜单按钮