Detecting Multiple Clicks

Scott Rossi scott at tactilemedia.com
Tue Jun 30 22:03:16 CEST 2015


Thought folks might find the following useful...

I currently have a situation where I need to detect multiple clicks on an
object and differentiate between the number of click sets (i.e.
single-click, double-click, triple-click, etc).  The following seems to
work well, detecting a 50-click event, after which point I got tired of
clicking :-)

-----

constant theClickThreshold = 300
local theClickCount, theClickID

on mouseDown
   if lineOffset("countClicks",pendingMessages()) = 0 then
      put 0 into theClickCount
   else cancel theClickID
   add 1 to theClickCount
   send "countClicks" to me in theClickThreshold millisecs
   put the result into theClickID
end mouseDown

command countClicks
   put theClickCount && millisecs() -- SHOW CLICK COUNT
   put 0 into theClickCount -- RESET
end countClicks

-----


The click threshold can be adjusted but seems to work well at 300
milliseconds.  Change "on mouseDown" to "before mouseDown" to implement as
a behavior.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design






More information about the use-livecode mailing list