3

一直玩风暴模拟器和4.7 JDE,对于我的生活,我无法弄清楚如何在模拟器中触发手势事件。黑莓风暴模拟器 - TouchGesture事件不开火,如何获得一个刷卡工作?

以下是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;  
} 

回答

4

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

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

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