Page 1 of 1

flushEvents("mouseUp")

Posted: Fri Jul 24, 2009 2:39 am
by edljr
Hi All,

I have read, and re-read all postings I could find regarding flushEvents, lock messages, and other key phrases related to flushing the buffer of unwanted mouse clicks. What I have tried so far:

Overview
I have 12 images on the screen. A string of 3-5 images must be clicked in the correct order for a correct score. If a wrong image is clicked, I want to process that and not allow any further mouseUp messages.

Problem
Users can click on an incorrect image followed by any other image. The mouseUp from that subsequent click current carries over and is processed as the first guess to the next question.

Failed Attempt A
Setting the disabled of all the images immediately after any of the images is clicked.

Failed Attempt B
1. lock messages
2. process answer
3. unlock messages

Failed Attempt C
1. lock messages
2. get flushEvents("mouseUp")
3. process answer
4. unlock messages

Failed Attempt D
1. I created a global okayToClick
2. Play audio
3. okayToClick = true
4. upon mouseUp on any of the 12 images, okayToClick = false
5. The 12 images have an "if" statement to evaluate okayToClick
5A - if true, process the click (call a function)
5B - if false, do nothing

I spent considerable time with the documentation, this forum, and the listserv, but cannot seem to find the key. It is frustrating to get stuck on the little stuff.

Any help would be greatly appreciated.

Thanks,
Ed

Posted: Fri Jul 24, 2009 4:10 am
by paul_gr
try canceling pendingmessages at the end of the mouseUp handler.

Paul

flushEvents("mouseUp")

Posted: Fri Jul 24, 2009 4:20 am
by edljr
Thanks for the note, Paul.

I tried this:

Code: Select all

on mouseUp
   global okayToClick
   
   if okayToClick is "true" then
      put "false" into okayToClick
      processGuess(the short name of me)
      repeat until the pendingMessages is empty
         cancel item 1 of line 1 of the pendingMessages
      end repeat
   end if
end mouseUp
...and also tried tis:

Code: Select all

on mouseUp
   global okayToClick
   
   if okayToClick is "true" then
      put "false" into okayToClick
      repeat until the pendingMessages is empty
         cancel item 1 of line 1 of the pendingMessages
      end repeat
      processGuess(the short name of me)
   end if
end mouseUp
No luck.

Posted: Fri Jul 24, 2009 6:42 am
by mwieder
I think I would handle this differently:

(similar to your Failed Attempt A)
1. set the disabled of all the images
2. enable *only* the next image to be clicked
3. on mouseUp (in card or group handler)
if it's the last item that should be clicked you're done
else do it all over again (enable next image)

Posted: Wed Aug 05, 2009 3:22 pm
by roeg11
(sorry for the crosslisting--but my problem relates, maybe)

sometimes the mouseup message doesn't happen. I'm clicking and dragging and evaluating the new location on mouseup. But sometimes (I haven't seen a pattern) the mouseup doesn't appear in the message watcher and the location doesn't get evaluated.

The Dictionary has a note on "mouseup" that says something about a "transparent pixel" not registering a mouseup, but passing it to the next level or object or what...

I've checked and rebuilt the stack (it only contains a trial button and field) but nothing seems to matter.
thanks in advance