04-18-2012 08:14 AM
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 #
Solved! Go to Solution.
04-18-2012 08:20 AM
04-18-2012 09:29 AM
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.
04-18-2012 11:10 AM
@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.
04-19-2012 01:16 AM - edited 04-19-2012 01:20 AM
@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 #