Hi Cameron,
What I overlooked was the numlock key.
With numlock on
the Shift button is detected if right mouse button is clicked
the Shift button is not detected if left mouse button is clicked
the Alt key is not detected in either case.
the Ctrl key is not detected in either case.
With numlock off all works fine.
Patrick
Patrick Egan wrote:
Hi Cameron,
I have just tried the latest code from SVN and all is working fine now.
I must have overlooked something earlier.
Many thanks,
Patrick
Cameron McCormack wrote:
Hi Patrick.
Patrick Egan:
Just tried the code in SVN and I still not able to detect the modifier
keys.
I have tried both getAltKey() and casting to
org.apache.batik.dom.events.DOMMouseEvent to use getModifierState().
Here is some complete code that works for me, using Shift rather than
Alt. (Alt clicking is captured by my window manager.) Change the file
in the setURI call and let me know if it works.
// t.java
import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.swing.gvt.GVTTreeRendererAdapter;
import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
import org.apache.batik.dom.events.*;
import javax.swing.*;
import org.w3c.dom.*;
import org.w3c.dom.events.*;
public class t {
public static void main(String[] args) {
JFrame f = new JFrame();
final JSVGCanvas s = new JSVGCanvas();
s.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
f.getContentPane().add(s);
f.setSize(400, 400);
s.setURI("file:/tmp/t/t.svg");
f.show();
s.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
Document d = s.getSVGDocument();
EventTarget c = (EventTarget) d.getElementById("c");
c.addEventListener("click", new L(), false);
}
});
}
protected static class L implements EventListener {
public void handleEvent(Event evt) {
DOMMouseEvent mevt = (DOMMouseEvent) evt;
System.err.println("Shift: " + mevt.getShiftKey());
}
}
}
Important - This e-mail and the information that it contains may be
confidential, legally privileged and protected by law. Access by the
intended recipient only is authorised. Any liability (in negligence or
otherwise) arising from any third party acting, or refraining from acting,
on any information contained in this e-mail is hereby excluded. If you are
not the intended recipient, please notify the sender immediately and do not
disclose the contents to any other person, use it for any purpose, or store
or copy the information in any medium. Copyright in this e-mail and
attachments created by us belongs to the author and
also asserts the right to be identified as such and object to any misuse.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
|