xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Denis Bohm" <de...@fireflydesign.com>
Subject Re: grab DOM event?
Date Fri, 05 Sep 2003 22:39:14 GMT
> > Getting a mouseout event doesn't really help me.  I don't want to cancel
> > operation based on mouseout as the user could drag the mouse back into
> > window and then release.  I really need to get a mouseup and I don't
seem to
> > be getting one right now.  Should I get a mouseup with a null
>    Well if you got anything it would be a mouseup with a null 'target'
> but such a thing doesn't exist.  I understand your desire but it's
> also not 100% clear to me that we should deliver such an event (first
> off I think it would likely break lots of code that assumes there
> will always be a target).  Anyone else care to weigh in with opinions?
> I don't care for the target document or root because it just doesn't
> make sense.  Any what would you use for clientX/Y?  values outside of
> the viewport?  These of course of 'cleaness' arguments where as you
> have a solid need.
>    Anyway contributions are always welcome - if done well it would
> probably be accepted.

I made two changes to my copy of the Batik source, shown below, and now all
mouse events are processed and sent to the root if there is no target found.
It now works well in my application.  When the user presses on a slider then
I can register a grab listener at the root that stops propagation and
processes all events until the user releases the mouse or cancels the
operation - even when they drag outside the JSVGCanvas, etc.  It actually
simplifies the code and removes an odd text dummyNode that I noticed caused
a null pointer problem in some other area because it events were being
dispatched to the node, but it wasn't part of the document.

However, if people have written code to rely on only getting events to the
root when the mouse is over an element then this will effect that code.  I
wonder if that is common.  I looked around at some interactive SVG examples
on the web.  Seemed like most of them had the same problems that my code
used to have and some were trying the same kind of "tricks" like adding
invisible root elements, etc, which don't solve all the problems.

Seems to me the ability to get all events is essential to being able to
create interactive interfaces using SVG.

What do others think?




        protected void dispatchMouseEvent(String eventType,
                                          Element targetElement,
                                          Element relatedElement,
                                          Point clientXY,
                                          GraphicsNodeMouseEvent evt,
                                          boolean cancelable) {
            if (targetElement == null) {
                // -denis- dispatch to document if no target
                // return;
                targetElement = context.getDocument().getDocumentElement();


//    protected GraphicsNode dummyNode = new TextNode();
        // In all cases, dispatch the original event
// -denis- dispatch to root if no target
//        if (node != null) {
            gvtevt = new GraphicsNodeMouseEvent(node != null ? node : root,

            // node.processMouseEvent(gvtevt);
        } else if (node == null && evt.getID() == MouseEvent.MOUSE_CLICKED
              && evt.getClickCount() == 1) {
            gvtevt = new GraphicsNodeMouseEvent(dummyNode,


To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org

View raw message