Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse GEF
3.3

org.eclipse.gef
Class KeyHandler

java.lang.Object
  extended by
org.eclipse.gef.KeyHandler
Direct Known Subclasses:
GraphicalViewerKeyHandler

public class KeyHandler
extends java.lang.Object

The KeyHandler should handle all normal keystrokes on an EditPartViewer. Normal is simply defined as keystrokes which are not associated with an Accelerator on the Menu. The KeyHandler will be forwarded KeyEvents by the active Tool, which is usually the SelectionTool. The Tool may be in a state where keystrokes should not be processed, in which case it will not forward the keystrokes. For this reason, it is important to always handle KeyEvents by using a KeyHandler.

KeyHandlers can be chained by calling setParent(KeyHandler). If this KeyHandler does not handle the keystroke, it will pass the keystroke to its parent KeyHandler.

KeyHandlers can be implemented using two stragegies. One is to map KeyStrokes to Actions using the put(KeyStroke, IAction) and remove(KeyStroke) API. The other is to subclass KeyHandler, and override various methods. A combination of the two is also useful.

Since:
2.0

Constructor Summary
KeyHandler ()
           
 
Method Summary
 boolean keyPressed (KeyEvent event)
          Processes a key pressed event.
 boolean keyReleased (KeyEvent event)
          Processes a key released event.
 void put ( KeyStroke keystroke, IAction action)
          Maps a specified KeyStroke to an IAction.
 void remove ( KeyStroke keystroke)
          Removed a mapped IAction for the specified KeyStroke.
  KeyHandler setParent ( KeyHandler parent)
          Sets a parent KeyHandler to which this KeyHandler will forward un-consumed KeyEvents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyHandler

public KeyHandler()
Method Detail

keyPressed

public boolean keyPressed(KeyEvent event)
Processes a key pressed event. This method is called by the Tool whenever a key is pressed, and the Tool is in the proper state.

Parameters:
event - the KeyEvent
Returns:
true if KeyEvent was handled in some way

keyReleased

public boolean keyReleased(KeyEvent event)
Processes a key released event. This method is called by the Tool whenever a key is released, and the Tool is in the proper state.

Parameters:
event - the KeyEvent
Returns:
true if KeyEvent was handled in some way

put

public void put(
KeyStroke keystroke,
                
IAction action)
Maps a specified KeyStroke to an IAction. When a KeyEvent occurs matching the given KeyStroke, the Action will be run() iff it is enabled.

Parameters:
keystroke - the KeyStroke
action - the Action to run

remove

public void remove(
KeyStroke keystroke)
Removed a mapped IAction for the specified KeyStroke.

Parameters:
keystroke - the KeyStroke to be unmapped

setParent

public 
KeyHandler setParent(
KeyHandler parent)
Sets a parent KeyHandler to which this KeyHandler will forward un-consumed KeyEvents. This KeyHandler will first attempt to handle KeyEvents. If it does not recognize a given KeyEvent, that event is passed to its parent

Parameters:
parent - the parent KeyHandler
Returns:
this for convenience

Eclipse GEF
3.3

Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire