I want a doubleclick, not a singleclick

Ken Ray kray at sonsothunder.com
Sun Jul 31 01:35:17 EDT 2005


On 7/30/05 11:33 PM, "Chipp Walters" <chipp at chipp.com> wrote:

> I looked through the archives and didn't see an answer to this one-- so
> I thought I'd post my own :-)
> 
> If you have both a mouseUp and mouseDoubleUp handler in a single button
> script, both will be executed when you double-click the button.
> 
> But, what if you only want the mouseDoubleUp to execute and NOT the
> mouseUp? Well, I chatted this eve with Ken Ray and Jan Schenkel and came
> up with the following (they both had a bit of a different spin on it,
> perhaps they'll elaborate).

Thanks, Chipp... my version uses the pendingMessages to cancel the "doClick"
command if the user actually double-clicks:

on mouseUp
  send "doClick" to me in (the doubleClickInterval) milliseconds
end mouseUp

on mouseDoubleUp
  put lineOffset(",doClick,",the pendingMessages) into tLine
  if tLine <> 0 then cancel item 1 of line tLine of the pendingMessages
  --> doDoubleClickStuff
end mouseDoubleUp

on doClick
  --> doSingleClickStuff
end doClick

It's a bit shorter, but depends on the pendingMessages, so if you think some
external force may muck with the pendingMessages during the
doubleClickInterval you may wish to go another route. But it's worked for me
for years...

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com





More information about the use-livecode mailing list