You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Ben Drees <be...@apmindsf.com> on 2003/04/28 19:44:49 UTC

DOM Events and AWT Events

Hi,

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

My question:

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

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

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

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

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

Thanks for your help!

-- 
Ben Drees <be...@apmindsf.com>


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


RE: DOM Events and AWT Events

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "BD" == Ben Drees <be...@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 <be...@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