tags:

views:

211

answers:

1

I have a JSVGCanvas object from the Batik library from java. In my application, I am rendering several objects in a schematic. I require to know what component is below the mouse so I can render an appropiate tooltip and description that I am rendering from an external source.

My question is, how can I determine what objects are below the cursor at any given time?

+1  A: 

If you know the objects, for which you want to add tooltips and descriptions, you can add EventListeners to each Object. I did the same in my applciation.

For all relevant nodes, you do:

org.w3c.dom.events.EventTarget t = (EventTarget) node;
t.addEventListener("mouseover", new SvgOnHoverAction());

where SvgOnHoverAction implements org.w3c.dom.events.EventListener

there you do:

public void handleEvent(Event evt) {
    Element target = (Element)evt.getCurrentTarget();
    ...
}
räph
Good answer thanks! I ended up finding somewhere that you can also add a "title" element inside, but your solution is better!
Mario Ortegón