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
Trusted Contributor
Thecr0w
Posts: 178
Registered: ‎02-20-2011
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 #



Please use plain text.
Developer
simon_hain
Posts: 13,817
Registered: ‎07-29-2008
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
Please use plain text.
Developer
peter_strange
Posts: 17,713
Registered: ‎07-14-2008

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. 

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
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!
Please use plain text.
Trusted Contributor
Thecr0w
Posts: 178
Registered: ‎02-20-2011
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 #



Please use plain text.