Commit 87667b8c authored by campaign's avatar campaign

by zhanyi

parent 3de023b6
...@@ -28,5 +28,14 @@ var keymap = KityMinder.keymap = { ...@@ -28,5 +28,14 @@ var keymap = KityMinder.keymap = {
'NumLock':144, 'NumLock':144,
'Cmd':91 'Cmd':91,
'=':187,
'-':189,
"b":66,
'i':73,
'z':90,
'y':89
}; };
\ No newline at end of file
...@@ -87,25 +87,46 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -87,25 +87,46 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
_bindshortcutKeys: function () { _bindshortcutKeys: function () {
var me = this, var me = this,
shortcutkeys = this._shortcutkeys; shortcutkeys = this._shortcutkeys;
me.on( 'keydown', function ( e ) { function checkkey(key,keyCode,e){
switch(key){
case 'ctrl':
case 'cmd':
if(e.ctrlKey || e.metaKey){
return true;
}
break;
case 'alt':
if(e.altKey){
return true
}
break;
case 'shift':
if(e.shiftKey){
return true;
}
}
if(keyCode == keymap[key]){
return true;
}
return false
}
me.on( 'keydown', function ( e ) {
var originEvent = e.originEvent; var originEvent = e.originEvent;
var keyCode = originEvent.keyCode || originEvent.which; var keyCode = originEvent.keyCode || originEvent.which;
for ( var i in shortcutkeys ) { for ( var i in shortcutkeys ) {
var tmp = shortcutkeys[ i ].split( ',' ); var keys = shortcutkeys[ i ].toLowerCase().split('+');
for ( var t = 0, ti; ti = tmp[ t++ ]; ) { var current = 0;
ti = ti.split( ':' ); utils.each(keys,function(i,k){
var key = ti[ 0 ], if(checkkey(k,keyCode,originEvent)){
param = ti[ 1 ]; current++;
if ( /^(ctrl)(\+shift)?\+(\d+)$/.test( key.toLowerCase() ) || /^(\d+)$/.test( key ) ) {
if ( ( ( RegExp.$1 == 'ctrl' ? ( originEvent.ctrlKey || originEvent.metaKey ) : 0 ) && ( RegExp.$2 != "" ? originEvent[ RegExp.$2.slice( 1 ) + "Key" ] : 1 ) && keyCode == RegExp.$3 ) ||
keyCode == RegExp.$1
) {
if ( me.queryCommandState( i, param ) != -1 )
me.execCommand( i, param );
e.preventDefault();
}
} }
});
if(current == keys.length){
if ( me.queryCommandState( i ) != -1 )
me.execCommand( i );
originEvent.preventDefault();
break;
} }
} }
......
...@@ -69,8 +69,8 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -69,8 +69,8 @@ KityMinder.registerModule( "basestylemodule", function () {
} ) } )
}, },
addShortcutKeys: { addShortcutKeys: {
"bold": "ctrl+66", //bold "bold": "ctrl+b", //bold
"italic": "ctrl+73" //italic "italic": "ctrl+i" //italic
}, },
"events": { "events": {
"beforeRenderNode": function ( e ) { "beforeRenderNode": function ( e ) {
......
...@@ -138,8 +138,8 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -138,8 +138,8 @@ KityMinder.registerModule( "HistoryModule", function () {
} ) } )
}, },
addShortcutKeys: { addShortcutKeys: {
"Undo": "ctrl+90", //undo "Undo": "ctrl+z", //undo
"Redo": "ctrl+89" //redo "Redo": "ctrl+y" //redo
}, },
"events": { "events": {
"saveScene": function ( e ) { "saveScene": function ( e ) {
......
...@@ -62,7 +62,7 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -62,7 +62,7 @@ KityMinder.registerModule( 'Zoom', function () {
'zoom-out': ZoomOutCommand 'zoom-out': ZoomOutCommand
}, },
addShortcutKeys: { addShortcutKeys: {
"zoom-in": "+", //= "zoom-in": "=", //=
"zoom-out": "-" //- "zoom-out": "-" //-
}, },
events: { events: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment