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
Posts: 329
Registered: ‎12-17-2010
My Device: Not Specified
My Carrier: developer

how to handle Touch Screen ..

[ Edited ]

My problem is this :

               Hi all i have developed one Screen with some fields .... when any field has focus then i click on Screen where there is no field (empty space ) that field which has focus is getting called ...

 

I have done like this :

i have handled fields using navigationClick()

 

here i am taking field using method  

 

Field field = getLeafFieldWithFocus();

 

and i am comparing this field if it satisfied then doing some functionality here..

Finally:

can you please how to avoid the above this.  

Regular Contributor
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
My Carrier: Verizon

Re: how to handleTouch Screen ..

Normally, I override touchEvent() on screen like this

protected boolean touchEvent(TouchEvent message) {
		// TODO Auto-generated method stub
		int x = message.getX(1);
		int y = message.getY(1);
		int eventCode = message.getEvent();
		
		Field myField = (Field)MyScreen.this.getField(0);
		if(myField.getExtent().contains(x, y)){
			if(eventCode == TouchEvent.DOWN || TouchEvent.CLICK){
				//do your action
				return false;
			}
		}
		
		return super.touchEvent(message);
	}

 

 Maz

Developer
Posts: 329
Registered: ‎12-17-2010
My Device: Not Specified
My Carrier: developer

Re: how to handleTouch Screen ..

But io am using navigation click because i want my application in both touch and no-Touch mobiles .. 

 

And one when i click on labelField (it is Focusable)  it is showing all the menuItems which i have But i dont want to show all how handle that .. please help me out from here... 

Developer
Posts: 179
Registered: ‎06-15-2011
My Device: Storm 9550
My Carrier: Vodaphone

Re: how to handleTouch Screen ..

regarding 2 issue, I assume you want to remove menu which appears on click event. This can be done by returning true in navigationClick().
Regular Contributor
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
My Carrier: Verizon

Re: how to handleTouch Screen ..


satish4ru wrote:

But io am using navigation click because i want my application in both touch and no-Touch mobiles .. 

 

And one when i click on labelField (it is Focusable)  it is showing all the menuItems which i have But i dont want to show all how handle that .. please help me out from here... 


For issue that to check for touch and non-touch device. I use this method

 

public boolean checkForTouchScreen(){
       if (DeviceInfo.getDeviceName().startsWith("95") || DeviceInfo.getDeviceName().startsWith("98") || DeviceInfo.getDeviceName().startsWith("99")){
          return true;
       }else {
          return false;
       }
    }

 Then I use this one to check when user "click" or "touch" any field like this

 

ButtonField btf = new ButtonField("Click or Touch"){
       protected boolean navigationClick(int status, int time) {
             if(checkForTouchScreen()==false){
		     //do your action
	     }
             return true;
       };
}

 

For your labelField

 

LabelField lbf = new LabelField("Can't click"){
       protected boolean navigationClick(int status, int time) {
             return true;
       };
}

 

Maz