Yeah, the section on interaction was what brought me here.  I thought
there'd be a value for the pointer-events tag that pushed events to the
parent or absorbed events from the children.

I'm trying to avoid having separate listeners for every group that I
add.  As it stands now, I have one mouse listener per document and it'd
be a pain to break that paradigm.  The idea about the IDs is specific to
my project.  I was thinking of something like this (regarding the IDs):

public void handleEvent(Event event) {
   final DOMMouseEvent elementEvent = (DOMMouseEvent) event;
   Element targetElement = (Element) event.getTarget();
   
   (Pseudocode)
   if (targetElement doesn't have an ID) {
      targetElement = (Element) targetElement.getParentNode();
   }

   // Now we can operate on the intended element.
   ...
}

I think this might work, assuimg that I set the children to
pointer-events="visible" (or let them inherit from the group tag).
Would this work?  In my case, it'd be easier than a new listener.

Michael Bishop

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> On Behalf Of Archie Cobbs
> Sent: Thursday, January 03, 2008 4:38 PM
> To: [email protected]
> Subject: Re: Pointer events for a <g> tag?
> 
> If you haven't already, read http://www.w3.org/TR/SVG/interact.html
> 
> The presence of an "id" attribute is not relevant. What 
> matters is the "pointer-events" attribute. Note that the 
> default value is "inherit". 
> 
> If you turn off pointer events on the inner nodes, no events 
> will happen, so don't do that.
> 
> If you have something like this:
> 
>   <g pointer-events="all">
>      <rect ..>      <!-- note: we inherit the "all" value for 
> pointer-events --> 
>      <line ..>
>   </g>
> 
> and then listen for events on the <g> node, then you should 
> receive any clicks on the <rect> or <line> as they bubble up. 
> Note in any case you won't receive events for clicks that are 
> not directly on either the <rect> or the <line>. 
> 
> 
> On Jan 3, 2008 3:22 PM, Bishop, Michael W. CONTR J9C880 
> <[EMAIL PROTECTED]> wrote:
> 
> 
>       OK, then I'm doing something wrong and I need to 
> explain a little more.
>       
>       I have a single listener that's attached to the entire 
> document.  I want
>       to drag and drop objects around my SVG document with 
> few exceptions: 
>       
>       <svg id="...">
>       
>         (This rectangle is here specifically to provide a 
> background color).
>         <rect type="background" id="..." ... />
>       
>         (Special metadata is included as an attribute to 
> define this element 
>       as a layer).
>         <g type="layer" id="...">
>       
>            (Each of these children can be dragged and dropped)
>            <rect id="..." pointer-events="visible" ... /> 
>            <ellipse id="..." pointer-events="visible" ... />
>            <line id="..." pointer-events="visible" ... />
>       
>            (Special metadata is included as an attribute to 
> define this 
>       element as a group.
>             I want to drag and drop the GROUP, not the 
> elements within!  I
>       know this doesn't
>             work, but this is what I currently have.  I tried 
> to make the
>       individual elements
>             ignore events so the <g> would receive them.  
> Obviously it didn't 
>       work; the
>             background rect receives the event.)
>            <g type="group" id="..." pointer-events="visible">
>               <circle pointer-events="none" ... /> 
>               <line pointer-events="none" ... />
>            </g>
>         </g>
>       </svg>
>       
>       I want any clicks on the group's children to bubble up 
> to the group, but
>       it sounds like that's not possible with a single 
> listener.  Is there a 
>       way I can customize or work around that?  I'm thinking 
> that if an
>       element does not have an "id" node, it bubbles up until 
> it hits a parent
>       that does?
>       
>       Michael Bishop
>       
> 
> 
>       > -----Original Message-----
>       > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ]
>       > On Behalf Of Archie Cobbs
>       > Sent: Thursday, January 03, 2008 4:08 PM
>       > To: [email protected]
>       > Subject: Re: Pointer events for a <g> tag? 
>       >
>       > Not sure what you're asking exactly, but mouse events have a
>       > bubble phase during which they pass upwards in the DOM to the
>       > root node.
>       >
>       > If you listen for mouse events on the <g> tag (only), you'll 
>       > receive them there when they bubble up from the rect,
>       > ellipse, and line nodes.
>       >
>       >
>       > On Jan 3, 2008 3:03 PM, Bishop, Michael W. CONTR J9C880
>       > < [EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]> > wrote:
>       >
>       >
>       >       Given the following:
>       >
>       >       <g pointer-events="visible">
>       >         <rect .../>
>       >         <ellipse .../> 
>       >         <line .../>
>       >       </g>
>       >
>       >       I want to treat the inner elements of the <g> tag as a
>       > single entity.  I
>       >       want to be able to drag and drop them as a single 
>       > element.  I thought
>       >       wrapping them in a <g> tag and having the <g> tag
>       > respond to pointer
>       >       events was the solution.  Upon further research, it
>       > seems pointer events 
>       >       only work for graphics elements and a <g> tag isn't
>       > technically rendered
>       >       to the screen.
>       >
>       >       So how can I treat this group of elements as a single
>       > "group" and have 
>       >       them respond to pointer events as a whole?
>       >
>       >       Michael Bishop
>       >
>       >
>       > 
> ---------------------------------------------------------------------
>       >       To unsubscribe, e-mail: 
>       > [EMAIL PROTECTED]
>       >       For additional commands, e-mail:
>       > [EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]> 
>       >
>       >
>       >
>       >
>       >
>       >
>       > --
>       > Archie L. Cobbs
>       >
>       >
>       
>       
> ---------------------------------------------------------------------
>       To unsubscribe, e-mail: 
> [EMAIL PROTECTED]
>       For additional commands, e-mail: 
> [EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]> 
>       
>       
> 
> 
> 
> 
> --
> Archie L. Cobbs
> 
> 

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

Reply via email to