If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

FieldChangeListener gets invoke even when clicked outside Objectchoicefield in Touch Devices

On a screen there is objectchoicefield. In touch Device(9850), when i touch in same manager fieldchangelistener for objectchoicefield gets invoked.

I reffered following link. Still facing same problem :

http://supportforums.blackberry.com/t5/Java-Development/navigationClick-invoked-when-clicking-outsid...

 

This link works for BitmapField but not for ObjectChoiceField.

 

Also added Nullfield before adding Objectchoicefield with Field.FOCUSABLE. Still unable to fix issue.

Please use plain text.
Developer
simon_hain
Posts: 15,908
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: FieldChangeListener gets invoke even when clicked outside Objectchoicefield in Touch Devices

maybe you can do some check within the fieldchangelistener
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: FieldChangeListener gets invoke even when clicked outside Objectchoicefield in Touch Devices

I have checked in fieldchangelistener that field thats get clicked is this objectchoicefield or not. But it doesnt help.
Please use plain text.
Developer
hemant_sain
Posts: 178
Registered: ‎12-09-2011
My Device: 9360, BB10
My Carrier: Aircel

Re: FieldChangeListener gets invoke even when clicked outside Objectchoicefield in Touch Devices

try to give the static coordinates of your screens in Touch event.

 

you can also use the XYRect arround only ur clickable area.

Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: FieldChangeListener gets invoke even when clicked outside Objectchoicefield in Touch Devices

How can i do it? Can you give some Sample?
Please use plain text.
Developer
hemant_sain
Posts: 178
Registered: ‎12-09-2011
My Device: 9360, BB10
My Carrier: Aircel

Re: FieldChangeListener gets invoke even when clicked outside Objectchoicefield in Touch Devices

you can try this one may be it will help:

 

protected boolean touchEvent(TouchEvent event) 
			{
				int touchEventType = event.getEvent();
				int x = event.getX( 1 );
		        int y = event.getY( 1 );
		        
				switch (touchEventType) 
				{
				case TouchEvent.GESTURE:
					int gestureType = event.getGesture().getEvent();
	            	XYRect xy = this.getExtent();
	            	if(x > 0 && y > 0 && x < xy.width && y < xy.height)
	            	{
		            	if(gestureType == TouchGesture.TAP | gestureType == TouchGesture.DOUBLE_TAP)
		            	{
		            		//your action what u want to do.
		            	}
	            	}
					return true;
				case TouchEvent.CANCEL:
					return true;
				default:
					return super.touchEvent(event);
				}
			}

 

Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: FieldChangeListener gets invoke even when clicked outside Objectchoicefield in Touch Devices

Doesnt work. When i touch outside touchEvent is not invoked. But when touch on objectchoicefield touchEvent doesnt get invoked either.
Please use plain text.
Developer
StevenKader
Posts: 635
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: FieldChangeListener gets invoke even when clicked outside Objectchoicefield in Touch Devices

I think I faced the same thing and added this code in :

 

protected boolean touchEvent(TouchEvent message) {
		int event = message.getEvent();
		System.out.println("Event = " + event);
		switch (event) {

		case TouchEvent.CLICK:
		case TouchEvent.DOWN:
			System.out.println("Click/Down");
			// If we currently have the focus, we still get told about a click
			// in a different part of the screen
			if (touchEventOutOfBounds(message)) {
				return false;
			}


private boolean touchEventOutOfBounds(TouchEvent message) {
		// return true;
		int x = message.getX(1);
		int y = message.getY(1);
		
		int left = _currentValue + _leftCapWidth  ;
		int right = _currentValue  + _leftCapWidth + _thumbWidth;
		
		return ((x < left  || x > right ) || y < 0) ;
	}

 

 


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: FieldChangeListener gets invoke even when clicked outside Objectchoicefield in Touch Devices

Thanks for reply. Can you please explain what is _currentValue ,_leftCapWidth and _thumbWidth ?
Please use plain text.