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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Super Contributor
tolmachevroman
Posts: 257
Registered: ‎05-05-2011
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.)?  

Please use plain text.
Developer
superdirt
Posts: 503
Registered: ‎05-17-2009

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.

Please use plain text.
Super Contributor
tolmachevroman
Posts: 257
Registered: ‎05-05-2011
My Carrier: AT&T

Re: Implement trackwheel actions

thanx, now it works. :smileyhappy: 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;
	 }

 

Please use plain text.