Now I also noticed that I don't get any mouse-events while holding Ctrl or Shift down. So any help to solve these problems, would be much appreciated. I'm assuming I don't only need to remove the KeyEventListeners, but also the MouseListeners to solve this.
 
// Henric Rosvall


Från: Henric Rosvall [mailto:[EMAIL PROTECTED]
Skickat: den 9 mars 2006 16:17
Till: [email protected]
Ämne: Override keyevents

I have a class that extends JSvgCanvas.
Now I want to have my own key-event-handlers and disable the default ones. For example, I want to be able to "select" multiple objects when holding down the Ctrl-key, but right now, holding down the Ctrl-key will make it drag a zoom-box instead.
 
I tried the following code (which will probably make more experienced Java-devellopers will probably laugh your asses of), but to no avail:
  // Tell the Canvas not to use the Tab-key to move to the next control
  this.setFocusTraversalKeysEnabled(false);
  
// Remove all the current KeyListeners
  KeyListener[] kl = this.getKeyListeners();
  for (int x = 0; x < kl.length; x++)
   this.removeKeyListener(kl[x]);
  
  // Implement a Key-listener for Tab, Ctrl, Shift and Delete-Key-Presses
  this.addKeyListener(new JSvgCanvasEnhKeyHandler());
 
 
 
Regards
Henric Rosvall

Reply via email to