Search code examples
javadomcanvassvgcursor

JSVGCanvas.setCursor does not change cursor over SVGDocument


Why: setCursor(cursor) over a JSVGCanvas; the cursor changes correctly unless there is a SVG document displayed in the JSVGCanvas, in that case the default cursor comes back ?

icon = ImageIO.read(this.getClass().getResource("paintbrush.gif"));
Cursor c = Toolkit.getDefaultToolkit().createCustomCursor(icon, point, "brush");
jSVGCanvas.setCursor(c);

Solution

  • I found the answer to this question here SVG programming. You have to insert cursor tags into the SVG file.

    For that you must add a cursor="auto" to each part of the SVG document where you want the cursor to be modified when passing over with the mouse. You must also override the setCursor() method of your SVGCanvas and leave it empty !!

    <rect cursor="auto" class="cls-3" x="0.2" y="0.2" width="10.0" height="5.88"/>
    <rect cursor="auto" class="cls-4" x="0.2" y="0.2" width="30.0" height="20.0"/>