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
Trusted Contributor
Posts: 178
Registered: ‎02-20-2011
My Device: 8700
My Carrier: at&t
Accepted Solution

fieldChanged()?

Hi all here,

I made a button with two state, and I find that: when I click it through keyboard, its state was changed once (e.g: true->false); when I click it through touchscreen, its state was unexpectedly changed twice(e.g: true->false->true). I have not ever used the 2nd arg context of fieldChanged(Field field, int context), Does it has somthing to do with my problem, or there is other solutions? Thanks in advance.

 

		    public void fieldChanged(Field field, int context)
		    {
		    	// TODO Auto-generated method stub
		    	if(list.getActionState() == true) {
		    		startDownload(list);
		    	} else {
		    		stopDownload();
		    	}
		    }

 

 

# I tried to change the world, but I couldn't find the source code #



Developer
Posts: 16,676
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: fieldChanged()?

i usually check for context != FieldchangeListener.PROGRAMMATIC, maybe it helps in this case as well.
----------------------------------------------------------
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
Developer
Posts: 19,628
Registered: ‎07-14-2008
My Device: Not Specified

Re: fieldChanged()?

Do you have a touchEvent or navigationClick methods overridden?

 

Put a break point in the fieldChanged method and figure out what processing is being used to drive each change. 

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: fieldChanged()?

@simon_hain: I believe PROGRAMMATIC is a bitmask, so you'd better check

if (context & FieldChangeListener.PROGRAMMATIC != FieldChangeListener.PROGRAMMATIC)

 

@peter_strange: completely agree, the symptoms strongly suggest an incorrectly overridden touchEvent.

 

To the OP: don't forget - touchEvent is called many more times than the number of touches. For example, I personally found that on Storm (with its surepress technology) a single click produced the following touch events:

- DOWN

- DOWN (don't ask me why DOWN is sent twice, I'm still at a loss here)

- CLICK

- UNCLICK

- UP

Make sure you check the event type before processing and return super.touchEvent if you don't want to process this particular one.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Trusted Contributor
Posts: 178
Registered: ‎02-20-2011
My Device: 8700
My Carrier: at&t

Re: fieldChanged()?

[ Edited ]

@Peter, Thank you, you are right! and thanks for all replies.

# I tried to change the world, but I couldn't find the source code #