FIGUE
*Tutorial *Previous *Current *Next

Event Handling : Receiving Keyboard Events

* Step by Step

Import the usual figue packages.
import figue.*;
import figue.box.*;
import figue.path.*;
import figue.resource.*;
import figue.selection.*;
Import the event package.
import figue.event.*;
Add a custom key listener to an interactive facade.
_facade.addKeyListener (new KeyListenerInterface() {
   public final void keyTyped(KeyEvent anEvent) {
     ...
   }
   public final void keyPressed(KeyEvent anEvent) {
     ...
   }
   public final void keyReleased(KeyEvent anEvent) {
     ...
   }
});
Check and react to the events.
public final void keyPressed(KeyEvent anEvent) {
   switch ( anEvent.getKeyCode() ) {
   case KeyEvent.VK_A:
   ...
   case KeyEvent.VK_Y: {
       insertChar(anEvent.getKeyChar());
       break;
   }
You can also specialize the default key listener (the one that manages page up/down, home/end, left/right, up/down).
class NumberListener extends DefaultKeyListener {
   public NumberListener(InteractiveFacade aFacade) {
     super(aFacade);
   }
   public final void keyPressed(KeyEvent anEvent) {
     switch ( anEvent.getKeyCode() ) {
        case KeyEvent.VK_0:
        ...
	case KeyEvent.VK_NUMPAD9: {
	   insertChar(anEvent.getKeyChar());
           break;
        }
        default: {
	   super.keyPressed(anEvent);
	}
...
}
_facade.addKeyListener(new NumberListener(_facade));
Specify a policy for the focus management.
_facade.addPointingListener(new PointingListenerInterface() {
    public final void mouseEntered(PointingEvent anEvent) {
       _facade.requestFocus();
    }
...

* Example

Accelerators :
home, end, page up, page down, left arrow,right arrow, up arrow, down arrow.
Autoscrolling :
drag the mouse inside the text area, approach a border or a corner, and wait.
Actions :
- move the mouse over the text area,
- type alphanumeric characters.

* The Whole Program

* Related Classes and Methods

* What Next ?

Now you can :

*Tutorial *Previous *Current *Next

Comments or suggestions?
Need some help?
Copyright ©1998 INRIA
Last updated 4 November 1998 by Bruno Conductier
FIGUE