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();
static public function getApplicationMap():ShortcutMapReturns the main application keys map.
static public function addType(type:String, scopeMethod, parsingMethod:Function):VoidAdds new type to shortcut map.
Uses this method to add custom shortcut handler type.
public function registerCommand(shortcut:KeyDefinition, command:Command):Boolean
Registers passed-in shortcut with command Command.
Example
map.registerCommand( Keyboard.onKeyA, new MyCommand() );
shortcut | KeyDefinition object |
command | A Pixlib compliant Command |
true if registration is ok
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, ... ) );
shortcut | KeyDefinition object |
listener | Event listener |
... |
true if registration is ok
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 }
type | Shortcut processing type |
shortcut | KeyDefinition object |
o |
true if registration is ok
public function isRegistred(shortcut:KeyDefinition):Boolean
Returns true if passed-in shortcut is registred in map.
shortcut | A KeyDefinition object |
true if shortcut is registred