It doesn't seem to matter what SVG document I use, but for example this:
<svg>
<rect id="pressme" x="128" y="128" width="128" height="128" fill="blue"/>
</svg>
tested with the following code:
public class TestKeys
{
JSVGCanvas canvas = new JSVGCanvas();
JFrame frame = new JFrame();
EventListener keyPresses = new EventListener()
{
public void handleEvent(Event evt)
{
System.out.print("*");
}
};
public TestKeys()
{
frame.getContentPane().add(canvas);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
canvas.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter()
{
public void documentLoadingStarted(SVGDocumentLoaderEvent e)
{
Logger.getLogger("debug").info("loading svg...");
}
public void documentLoadingCompleted(SVGDocumentLoaderEvent e)
{
Logger.getLogger("debug").info("loaded");
canvas.setDisableInteractions(true);
SVGElement element =
(SVGElement)canvas.getSVGDocument().getElementById("pressme");
((EventTarget)element).addEventListener("keypress", keyPresses, false);
}
});
canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
canvas.setProgressivePaint(true);
canvas.setURI("file:c:/projects/svg/testKeys.svg");
frame.setVisible(true);
}
public static void main(String[] i) throws Exception
{
TestKeys k = (TestKeys)TestKeys.class.newInstance();
}
}
The event handler does not receive keypress events for the following keys:
left,right,up,down,home,end,insert,tab,pageup,pagedown,numlock,capslock, or and f-keys.
_____________________________________________________________
[EMAIL PROTECTED]
http://www.digiverse.net
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]