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
Super Contributor
Posts: 257
Registered: ‎05-05-2011
My Device: 9700
My Carrier: AT&T
Accepted Solution

Implement trackwheel actions

Hi everyone,

 I want to implement listener for UP, DOWN, LEFT, RIGHT trackwheel events. I'm using Keypad interface and in it's documentation it is said to override navigationClick this way:

 

 public boolean navigationClick(int status, int time) 
	 {
	     if ((status & KeypadListener.STATUS_TRACKWHEEL) == KeypadListener.STATUS_TRACKWHEEL) 
	     {
	    	
	     } 
	     else if ((status & KeypadListener.STATUS_FOUR_WAY) == KeypadListener.STATUS_FOUR_WAY) 
	     { 

             }
	     return super.navigationClick(status, time); 
	 }

 

 But, how do I know the direction (right or left etc.)?  

Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Implement trackwheel actions

[ Edited ]

navigationClick() triggers when a "click" occurs but doesn't detect left/right/up/down movement on the trackpad. If you want to detect movement, override navigationMovement() instead.

 

Scott

 

edit: PS - when the API refers to a "trackwheel", it is reffering the the roller wheel found on the older BB devices.

Super Contributor
Posts: 257
Registered: ‎05-05-2011
My Device: 9700
My Carrier: AT&T

Re: Implement trackwheel actions

thanx, now it works. Smiley Happy The code I use is:

 

 protected boolean navigationMovement(int dx, int dy, int status, int time) {
		 if(dx < 0 && dy == 0) {
			 System.out.println("______________________________________LEFT");
			 } else if(dx > 0 && dy == 0) {
			 System.out.println("______________________________________RIGHT");
			 } else if(dx == 0 && dy > 0) {
			 System.out.println("______________________________________DOWN");
			 } else if(dx == 0 && dy < 0) {
			 System.out.println("______________________________________UP");
			 }   
		 return true;
	 }