Hi Tom,

Tom Cohen wrote:

I'm new to SVG and pretty new to Java, so be gentle - I'm trying to to get a standalone program going using JSVGCanvas; I have a simple SVG file that has a large image file as background, and the SVG viewport gives me a view on that that can (as per the online documentation example) be dragged around the image.

    I assume you really mean 'viewBox'.  The viewport is what the
viewBox is mapped to, to provide the view, in general the viewport
is fixed by the size of the JSVGCanvas.

The problem is that the directional keyboard shortcuts that the JSVGCanvas allows don't always work well with that - the arrow keys are grabbed by the JSVGCanvas and moves the viewport around the canvas, not around the underlying document.

   The arrow keys update the 'currentTranslate' on the root SVG element.
You are correct that they don't effect the viewBox (so in
general you will get clipping, unless you set 'overflow="visible"'
on the svg element with the viewBox attribute).  This is a basic
problem with viewBox, it is good for setting the complete view
but I don't think it is especially good for what you want to do
(provide a moving view into a large document), this is the intent
of the currentScale/Translate attributes on the root SVG element,
but they are a bit tricker for users to understand.

This does make sense, so I've been trying to think of ways to layer objects so the canvas works on the underlying image, but can't. The best I can think of is to disable the arrow keys so the user can only drag the image. Not optimal. Is there a way I can pass the JSVGCanvas keyboard controls to control the viewport of the SVG object?

   Well if you disable the Canvas's use of the arrow keys you can
grab them in script/Java in your application and do what ever you want
to with them.

If anyone has any suggestions, please feel free to throw them out there.

   I'm still not real sure I understand what you are trying to do
but I suspect that you can work with the current arrow key stuff. I'll
also say that if your document is otherwise static the arrow key way
of moving the document around is _much_ more efficient.  In a dynamic
document the two are mostly equivalent.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to