Class fever.app.accelerator.ShortcutMap

Description

Defines shortcut mapping.

ShortcutMap allows shortcuts switching during application life.
You can load() or unload() shortcut map when you want to activate or not keys accelerator.

Use fever.app.accelerator.ShortcutLocator.getMap() method to create or retreive defined shortcut map.

Example

   var map : ShortcutMap = ShortcutLocator.getMap( "map1" );
   map.registerEvent( Keyboard.onKeyCONTROL, this, _onKey );
   map.registerCommand( Keyboard.onKeyADD, new CommandTest() );
   
   // Using <strong>AsWing component</strong>
   var button1 : JButton = new JButton( "bouton 1 action" );
   button1.addActionListener( Delegate.create( this, _test1, "param" ) );
   
   var button2 : JButton = new JButton( "bouton 2 action" );
   button2.addActionListener( _test2, this );
   
   map.registerCustomType( FvAsWing.AWSHORTCUT, Keyboard.onKeySUBSTRACT, button1 );   map.registerCustomType( FvAsWing.AWSHORTCUT, Keyboard.onKeyADD, button2 );
   
   map.load();
 

See Also

Method Index

_clear(), addType(), clear(), getApplicationMap(), getName(), isRegistred(), load(), registerCommand(), registerCustomType(), registerEvent(), toString(), unload(), unregister()

Method Detail

getApplicationMap

static public function getApplicationMap():ShortcutMap

Returns the main application keys map.

addType

static public function addType(type:String, scopeMethod, parsingMethod:Function):Void

Adds new type to shortcut map.

Uses this method to add custom shortcut handler type.

registerCommand

public function registerCommand(shortcut:KeyDefinition, command:Command):Boolean

Registers passed-in shortcut with command Command.

Example

 	 map.registerCommand( Keyboard.onKeyA, new MyCommand() );
 

Parameters

shortcutKeyDefinition object
commandA Pixlib compliant Command

Return

true if registration is ok

registerEvent

public function registerEvent(shortcut:KeyDefinition, listener):Boolean

Registers passed-in shortcut with listener event listener.

Valid call are :

 	 map.registerEvent( Keyboard.onKeyA, this );
   map.registerEvent( Keyboard.onKeyA, this, _onMyKey );   map.registerEvent( Keyboard.onKeyA, this, _onMyKey, param1, param2, ... );   map.registerEvent( Keyboard.onKeyA, Delegate.create( this, _onMyKey ) );   map.registerEvent( Keyboard.onKeyA, Delegate.create( this, _onMyKey, param1, param2, ... ) );
 

Parameters

shortcutKeyDefinition object
listenerEvent listener
...

Return

true if registration is ok

registerCustomType

public function registerCustomType(type:String, shortcut:KeyDefinition, o:Object):Boolean

Registers passed-in shortcut with o event handler.

Use registerCommand() or registerEvent() for specific command or event registration.

type defines a specific o parsing when shortcut is activated.

Example :

   // Type identifier already exist in FvAsWing class for component <-> shortcut
   map.registerCustomType( FvAsWing.AWSHORTCUT, Keyboard.onKeyA, myButton );
   
   ShortcutMap.addType( "myOwnType", this, _getOwnType );
   
   function _getOwnType( o, event : KeyBoardEvent ) 
   {
   	// do someting
   }
 

Parameters

typeShortcut processing type
shortcutKeyDefinition object
o

Return

true if registration is ok

isRegistred

public function isRegistred(shortcut:KeyDefinition):Boolean

Returns true if passed-in shortcut is registred in map.

Parameters

shortcutA KeyDefinition object

Return

true if shortcut is registred

unregister

public function unregister(shortcut:KeyDefinition):Void

Unregisters passed-in shortcut from map.

Parameters

shortcutA KeyDefinition object

load

public function load():Void

Loads current map.

All shortcuts are enabled.

unload

public function unload():Void

Unloads current map.

All shortcuts are disabled.

clear

public function clear():Void

Clears all shorcuts

getName

public function getName():String

Returns current shortcut map name.

toString

public function toString():String

Returns string representation.

_clear

public function _clear():Void