[prev in list] [next in list] [prev in thread] [next in thread] 

List:       batik-users
Subject:    RE: DOM Events and AWT Events
From:       Thomas E Deweese <thomas.deweese () kodak ! com>
Date:       2003-04-28 17:53:04
[Download RAW message or body]

>>>>> "BD" == Ben Drees <ben@apmindsf.com> writes:

BD> I'm building a Batik-based graph editor. The editor listens for
BD> DOM UI events (via EventTarget.addEventListener() on "mousedown",
BD> "mouseup", and "click"). Since mouse-down, mouse-up, mouse-click,
BD> and mouse-drag events are not supported through this mechanism
BD> ***when they occur over whitespace***, the editor also listens for
BD> java.awt.event.MouseEvents by implementing MouseListener.

    The typical solution to this problem is to eliminate 'whitespace'
from the SVG document:

<svg ....>
   <rect id="unseenBackground" 
         x="-100%" y="-100%" width="300%" height="300%"
         fill="#FFF" fill-opacity="0.00001"/>

   <!-- Rest of document -->

</svg>

    This way you always get DOM events no matter where the cursor is.
Ideally you could use visibility="hidden" for this rect but for a
variety of reasons this doesn't work in Batik so use the opacity
'hack'.

BD> My question:

BD> Is there a way to filter out the java.awt.event.MouseEvents that
BD> get translated by Batik into DOM UI events so that each mouse
BD> action only appears in one callback or the other?

BD> For example, if the user clicks on a node, I get the following
BD> sequence:

BD> 1) DOM UI event: mousedown 2) AWT event: mousePressed 3) DOM UI
BD> event: mouseup 4) AWT event: mouseReleased 5) DOM UI event: click
BD> 6) AWT event: mouseClicked

BD> I would prefer to only receive events 1, 3, and 5 in this case,
BD> reserving the AWT events for mouse actions that occur over
BD> whitespace.

BD> I tried using Event.stopPropagation() and Event.preventDefault(),
BD> but they don't seem to address this problem. Am I missing
BD> something obvious here? Will I have to track, correlate, and
BD> filter the duplicate events myself?

BD> Thanks for your help!

BD> -- Ben Drees <ben@apmindsf.com>


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




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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic