You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Henric Rosvall <he...@swipnet.se> on 2006/03/09 16:16:55 UTC

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

Re: SV: Override keyevents

Posted by th...@kodak.com.
Hi Henric,

"Henric Rosvall" <he...@swipnet.se> wrote on 03/09/2006 10:32:47 
AM:

> 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.

    If you want to turn all of this off you can simply call
'canvas.setDisableInteractions(true)' (this also disables key actions).

    Otherwise you can call the various 'setEnableXXXInteractor(false)'.
methods on the canvas to turn them on/off individually.

> 
> // Henric Rosvall
> 
> Från: Henric Rosvall [mailto:henric.rosvall@swipnet.se] 
> Skickat: den 9 mars 2006 16:17
> Till: batik-users@xmlgraphics.apache.org
> Ä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

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


SV: Override keyevents

Posted by Henric Rosvall <he...@swipnet.se>.
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:henric.rosvall@swipnet.se] 
Skickat: den 9 mars 2006 16:17
Till: batik-users@xmlgraphics.apache.org
Ä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