Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
crispyoz
Posts: 223
Registered: ‎10-01-2011
My Device: Bold 9900
Accepted Solution

Swipe event works in simulator but not on device

[ Edited ]

I'm using panels on my 9900 and have 4 panels which the user will swipe back and forth similar to how BB app world works, changing from summary to reviews panels etc. 

 

My expection was that since the touchscreen swipe functions up and down, and the track pad has the same function by default, that left and right swipe on the screen  would also be the same as left and right swipe on the tack pad. But  it doesn't do anything to the panels when you use the trackpad. 

 

So I override NavigationMovement and and can see that both the touch screen and track pad generate an NavigationMovement event with +/- x depending on the direction of the swipe. So I am first puzzled why swiping the trackpad left and right doesn't trigger the same behaviour as swiping left and right on the touch screen.

 

Accepting that as a limitation in the API I added my own functionality to NavigationMovement to inject a touch event when the user swipes left or right on the track pad. Like so:

 

EventInjector.TouchEvent[] moveEvents = new EventInjector.TouchEvent[7];

moveEvents[0] = new EventInjector.TouchEvent(TouchEvent.MOVE, 420, 60, -1, -1, -1);
moveEvents[1] = new EventInjector.TouchEvent(TouchEvent.MOVE, 360, 60, -1, -1, -1);
moveEvents[2] = new EventInjector.TouchEvent(TouchEvent.MOVE, 300, 60, -1, -1, -1);
moveEvents[3] = new EventInjector.TouchEvent(TouchEvent.MOVE, 240, 60, -1, -1, -1);
moveEvents[4] = new EventInjector.TouchEvent(TouchEvent.MOVE, 180, 60, -1, -1, -1);
moveEvents[5] = new EventInjector.TouchEvent(TouchEvent.MOVE, 120, 60, -1, -1, -1);
moveEvents[6] = new EventInjector.TouchEvent(TouchEvent.MOVE, 60, 60, -1, -1, -1);
EventInjector.TouchEvent.injectSwipeGesture(480, 60, moveEvents);

 

This works perfectly in the simulator but on the device it doesn't make any movement at all. So I thought maybe the touchpad on the simulator is more sensitive than on the actual device, so I added a menu item to perform the injection above. Again it works perfectly on the simulator but nothing on the device.

 

Has anyone tried injecting this event left and right before?  Up and down injection works perfectly on the device.

 

 

BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Swipe event works in simulator but not on device

Did you enable event injection in the application permission settings for your application?  It is disabled by default.  You can do so by going to Options -> Application, select your app and choose Edit Permissions.  You can also request these permissions programmatically using the ApplicationPermission class.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
crispyoz
Posts: 223
Registered: ‎10-01-2011
My Device: Bold 9900

Re: Swipe event works in simulator but not on device

Thanks Mark,

 

I hadn't thought of that becasue I didn't know it existed :smileyhappy:  That fixed it. Thanks!