This might be a bit complicated to implement, but I think I have an idea
that will help.

For your links, instead of setting up click handlers, use mousedown and
mouseup handlers. When the initial mousedown event comes in, set some
flag ("timerActive" for instance) to true and start a timer (pick some
smallish number of milliseconds, like 50 or so). When the timer expires,
toggle the flag back to false. If the mouseup event comes in while the
timer flag is still true, treat it as a click and navigate... If,
however, the timer expires and the flag is false when the mouseup comes
in, then assume a drag was done, and don't do anything with the link.

You can probably extend the theory to be more complicated. For instance
if you click and hold down the mouse, but don't actually move the mouse
at all, then still treat it as a click since no dragging was
done...etc.. But the basic idea just might do the trick.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Gregory Hill
Sent: Monday, February 27, 2006 5:10 PM
To: rails-spinoffs@lists.rubyonrails.org
Subject: RE: [Rails-spinoffs] Disabling anchor clicking in a draggable

> When binding an event handler via DOM2 methods, the return value of 
> the functions does not matter. You stop the propagation by other 
> means, abstracted to Event.stop(event_object) in prototype.js
> 
> Bye,
>   Martin

The main problem is that Event.stop stops the onclick event, but it does
not stop the link from firing (at least, in my experience).  Use the
'handle' option to have another item be the actual draggable part (SPAN
is great for this).

Greg
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

The information transmitted in this electronic mail is intended only for the
person or entity to which it is addressed and may contain confidential,
proprietary, and/or privileged material.  Any review, retransmission, 
dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient
is prohibited. If you received this in error, please contact the sender and
delete the material from all computers.

_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to