You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Alberto Carrascal <al...@gmail.com> on 2013/01/18 10:57:53 UTC

Changing cursor when passing over Elements

Hi all,

I'm simply trying to change the cursor when passing over a known Element by
using this code:

((EventTarget) elem).addEventListener("mouseover", new EventListener() {

            @Override
            public void handleEvent(Event arg0) {

 canvas.getTopLevelAncestor().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

               arg0.stopPropagation() ;


            }
        }, false); // I've also tried with true


The problem is that the cursor changes only first time, but when I quit the
Element the cursor never change again.
Does anyone know a more elegante solution?

Thanks in advance!

Re: Changing cursor when passing over Elements

Posted by jonathan wood <jo...@gmail.com>.
Hello Alberto,

You can accomplish this pretty easily without the event listener.

The spec covers it here : http://www.w3.org/TR/SVG/interact.html#Cursors

w3c tests give a decent example:
http://www.w3.org/Graphics/SVG/Test/20030813/svggen/interact-cursor-01-f.svg





On Fri, Jan 18, 2013 at 4:57 AM, Alberto Carrascal
<al...@gmail.com>wrote:

> Hi all,
>
> I'm simply trying to change the cursor when passing over a known Element
> by using this code:
>
> ((EventTarget) elem).addEventListener("mouseover", new EventListener() {
>
>             @Override
>             public void handleEvent(Event arg0) {
>
>  canvas.getTopLevelAncestor().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
>
>                arg0.stopPropagation() ;
>
>
>             }
>         }, false); // I've also tried with true
>
>
> The problem is that the cursor changes only first time, but when I quit
> the Element the cursor never change again.
> Does anyone know a more elegante solution?
>
> Thanks in advance!
>