I want a doubleclick, not a singleclick

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

I want a doubleclick, not a singleclick

Chipp Walters
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).

Here's the guts:

local lDoubleClick

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

on mouseDoubleUp
   put true into lDoubleClick
end mouseDoubleUp

on doClick
   if lDoubleClick = true then
      --> doDoubleClickstuff
     put false into lDoubleClick
   else
     --> doSingleClickStuff
   end if
end doClick

best,

Chipp
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: I want a doubleclick, not a singleclick

Ken Ray
On 7/30/05 11:33 PM, "Chipp Walters" <[hidden email]> 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: [hidden email]


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution