Hi Matthew,

Matthew Wilson <[EMAIL PROTECTED]> wrote on 01/20/2008 04:47:11 PM:

> I have written a Swing component which wraps JSVGCanvas, and I would
> like to capture DOM mouse click events so that I can draw on the canvas
> where the user has clicked. So I register and define my event listener
> like this:

   Does your document have anything in it?
   If there is no content in the document there is nothing to click
(or move, or mouseover/out) with.  If you want to catch all events
on the canvas it's common to add a large rectangle that covers
the entire canvas (often done using percentages).

    <rect x="-1000%" y="-1000%" width="3000%" height="3000%"
            visibility="hidden" pointer-events="fill"/>

> public class PlanViewPanel extends JPanel implements MouseWheelListener,
> EventListener, SVGLoadEventDispatcherListener {
> 
> ....... stuff ......
> 
>    public PlanViewPanel(SVGDocument svg) {
>    svgCanvas.setDocument(svg);
>            svgCanvas.addMouseWheelListener(this); // this is for
> something else entirely
>           scrollPane = new JSVGScrollPane(svgCanvas);
>         scrollPane.setScrollbarsAlwaysVisible(true);
> 
> 
scrollPane.setPreferredSize(Toolkit.getDefaultToolkit().getScreenSize());
>         add(scrollPane);
>         setMinimumSize(new Dimension(800,600));
> 
> svgCanvas.getSVGDocument().getRootElement().addEventListener("click",
> this, false);
>    }
> 
>              .... stuff ....
>    public void handleEvent(org.w3c.dom.events.Event evt) {
>             System.out.println("did something");
> 
>        }
> 
> }
> 
> but my event handler is never called (I've placed a breakpoint and run
> it in the eclipse debugger to confirm this).  I have confirmed also
> using a debugger that the event handler is present in the hashtable in
> the document root's EventSupport structure, but I do not understand why
> it is not called. I have messed around with various different event
> types and tried bubble/capture, but nothing works.
> 
> Using JDK 1.6.0 and Batik 1.7.
> 
> Any suggestions would be greatly appreciated.
> 
> Matthew Wilson.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

Reply via email to