Wow, this issue seems to be a whole lot more complicated than I thought!
1. Mark,
The problem here is that polling the mouseClick function flushes the the mouseUp messages.
If I understand you correctly, are you saying: If a "repeat" loop polls the mouseClick, then the resultant mouseUp won't even be sent to the target of the click (which is the very purpose of the whole exercise!)
In my program, once I put in your first suggestion ("wait 0 millisecs with messages"), this happens only rarely. I take it that most of the time the mouseUp message gets sent to its target BEFORE the "repeat" loop polls and flushes it. Actually, I wonder why it doesn't happen more frequently!
2.
It isn't clear to me whether the user is supposed to keep the mouse pressed until the moment when OP expects the mouseClick to be true. I wonder if a simple "until the mouse is up" would do?
No, not at all. May be a little description of my app would help. It is to be used by children with hearing loss (most with a cochlear implant) who are learning to listen and talk. They are of toddler-preschooler age level. The app can be used with and/or without adult (parent/therapist) supervision. In one of the modules, the child is trying to discriminate among spoken sentences. Each card contains a scenario, with about 10 clickable areas (transparent buttons). The program speaks a sentence, and waits. If the child clicks within 10 seconds, it processes the click and gives feedback ("Correct", an animation, etc.). If there is no response for 10 seconds, it repeats the sentence. And, waits, again. Etc. So, the waiting is not while the mouse is kept pressed, but pure user inactivity. Does this info make any difference to any of your suggestions?
3. I am not entirely sure that I understand your second method. I am not trying store the time between mouseClicks (my variable name, gLastClickTime, may have misled you). The program plays an audio, puts the time into gLastClickTime, and waits. If there is a mouseClick, it is very important that a mouseUp is sent to the target, and is not handled through the repeat loop sending a message to the object (this is because I have a single mouseUp handler at the stack level that handles it for all clickable buttons. This way, we can easily add additional cards -- i.e., exercises -- with nearly no additional coding). I am not sure how I can modify your second method to my purposes.
4. Jacque,
For counting something as long as ten seconds, polling every quarter or half second is usually good enough.
For my purposes, half a second would be too long. If a click doesn't produce a response immediately, the child (user) is likely to click another button. 100 millisec should be okay, I guess.
Regards,
Sri.