Denis Bohm wrote:
Denis Bohm wrote:

I'm trying to implement dragging using DOM events.  Is there some way to
grab events so that I can make sure I get the corresponding mouse

release


(even if the release occurs outside the press element)?  Or do I need to
resort to Swing/AWT to do that?

This is ussually done using a 'glass pane' - a rectangle that covers the entire canvas and is typically the last element in the

document.


The rectangle should have 'visibility="hidden"' and initially
'pointer-events="none"' - when the user starts dragging you
change pointer-events to 'fill' - the rect will then capture all
events.

   You can also leverage the 'capture' phase of DOM events and
register your event listener on the root node of the document
using EventTarget.addEventListener, with 'true' for the third
argument.  This allows you to get all events before anyone else
normally does.  You can then use stopPropagation to stop others
from seeing the event (read DOM Events specification for more info).


I tried this approach and it seems to have a couple of problems:
1) When the mouse is moved over text areas the cursor still changes, even
though events are captured and not propagated.

Yes, there isn't much you can do about this other than what I suggested with pointer-events.

2) No mouse events are dispatched when the mouse is moved over areas in the
canvas that don't have any elements drawn.  The worst case here is that
mouse releases are lost if done in one of these areas.

Sure but this is easily fixed by putting a non-rendered rectangle behind all the content.

3) If you press the mouse within the JSVGCanvas, then drag outside the
canvas, then release the mouse - the release is not dispatched.

The last point seems like something that can't be worked around and could
use some handling in JSVGCanvas to pass the release event on - maybe with
the target being the document or root element?  The spec doesn't seem to say
anything about this kind of situation, or does it?

You should always recieve a mouseout event with a 'null' relatedTarget in this case. I don't think the SVG Specification deals with this directly.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to