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: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel
Accepted Solution

TouchEvent and fieldChange Listener Issue

Hi All,

 

I have used TouchEvent and fieldChange Listener in my app.

but probelm is that I can't activate fieldChangeListener in my app.

 

I am capturing few points on my popup screen using touch.

this workd OK

But there is a button on popup screen. The associated fieldchangeListner method never gets activated!!

 

Can any one help me?

the button get clicked only by trackball/touchpad

 

Thanks

Abhinav Tyagi

 

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: TouchEvent and fieldChange Listener Issue

Not had this problem myself.  Can you replicate this with a simple Popup screen that you can post here, so we can try it?

Developer
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel

Re: TouchEvent and fieldChange Listener Issue

Thanks Peter,

 

Here is the part of my code

 

public class myClass extends PopupScreen implements FieldChangeListener {
	
/// VARIABLES

	public myClass(int col) {

		super(new VerticalFieldManager(Manager.NO_HORIZONTAL_SCROLL),
				Screen.DEFAULT_CLOSE);
		

		VerticalFieldManager vfm = new VerticalFieldManager(
				VerticalFieldManager.FIELD_HCENTER
						| VerticalFieldManager.FIELD_VCENTER);

////..... few BITMAPS and GRAPHICS objects
////..... BITMAP FIELD

		btn = new ButtonField("OK", ButtonField.CONSUME_CLICK|ButtonField.FIELD_HCENTER);
		btn.setChangeListener(this);

		vfm.add(bitColourField);
		vfm.add(new LabelField(" "));
		vfm.add(bitSelectedField);
		vfm.add(btn);
		vfm.add(new LabelField(" "));
		this.add(vfm);

	}
	
	protected boolean touchEvent(TouchEvent touch) {

		int eventType = touch.getEvent();
		try {
			if (eventType == TouchEvent.DOWN || eventType == TouchEvent.CLICK) {
				System.out.println("Down/Click");
				

///// MY CODE realted to BITMAPS and GRAPHICS
				
				

			} else if (eventType == TouchEvent.CANCEL
					|| eventType == TouchEvent.UP
					|| eventType == TouchEvent.UNCLICK) {
				System.out.println("Cancel/Up/Unclick");

			} else if (eventType == TouchEvent.MOVE) {
				System.out.println("Move");

			} 

		} catch (Throwable e) {
			throw new RuntimeException(e.toString());
		}
		return true;
	}

	

	public void fieldChanged(Field field, int arg1) {
		System.out.println("Field Change Listener !!!"); 
		if(field == btn){
			pop();
			
		}
		
	}
	
	private void pop(){
		System.out.println("bye");
		UiApplication.getUiApplication().popScreen(this);
	}

//// OTHER METHODS...

	
}

 

Same problem also comes when I used Signature application code you shared in some post and inserted a button field on the screen itself to capture image instead of using the menu.

 

Right now Since I can't access button from touch event... I am using it's XY coordinates and detect that area in touch event and call the button method myself.

FieldChange listener is working using trackball/touchpad only !!!

 

Thanks

Abhinav Tyagi

 

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: TouchEvent and fieldChange Listener Issue

You overrode the touch events so you will have to manually call the FieldChangeListener yourself when you need it.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: TouchEvent and fieldChange Listener Issue

One other option might be to call super.touchEvent and let the normal ButtonField processing do this for you. 

Developer
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel

Re: TouchEvent and fieldChange Listener Issue

Peter,

I didn't get you. Can you explain it?

 

Thanks

Abhinav Tyagi

 

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Highlighted
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: TouchEvent and fieldChange Listener Issue

By returning true from processing the DOWN event you disrupt the normal processing of complex events such as MOVE, CLICK and so on (because you report to the system that you have fully processed the event).

 

You need to return super.touchEvent(message) instead - to let the BB framework do its thing and register that DOWN so that it can combine it with the subsequest events and generate the CLICK. It is preferable to returning false because by invoking super.touchEvent you let your PopupScreen process it as well.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel

Re: TouchEvent and fieldChange Listener Issue

It's working now Smiley Very Happy

 

Thanks a lot

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
Posts: 130
Registered: ‎10-26-2010
My Device: Blackberry Bold 9700

Re: TouchEvent and fieldChange Listener Issue

Hi 

I have the same issue ( kind of ).

Looks like on touch button is not getting any focus so field is not changing .

try this I hope this will work :

 

http://supportforums.blackberry.com/t5/Java-Development/button-would-not-accept-focus-if-touched/td-...

 

Regards

Developer
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel

Re: TouchEvent and fieldChange Listener Issue

thanks... but its working now

 

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot