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;
}