Commit 87667b8c authored by campaign's avatar campaign

by zhanyi

parent 3de023b6
......@@ -28,5 +28,14 @@ var keymap = KityMinder.keymap = {
'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", {
_bindshortcutKeys: function () {
var me = this,
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 keyCode = originEvent.keyCode || originEvent.which;
for ( var i in shortcutkeys ) {
var tmp = shortcutkeys[ i ].split( ',' );
for ( var t = 0, ti; ti = tmp[ t++ ]; ) {
ti = ti.split( ':' );
var key = ti[ 0 ],
param = ti[ 1 ];
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();
}
var keys = shortcutkeys[ i ].toLowerCase().split('+');
var current = 0;
utils.each(keys,function(i,k){
if(checkkey(k,keyCode,originEvent)){
current++;
}
});
if(current == keys.length){
if ( me.queryCommandState( i ) != -1 )
me.execCommand( i );
originEvent.preventDefault();
break;
}
}
......
......@@ -69,8 +69,8 @@ KityMinder.registerModule( "basestylemodule", function () {
} )
},
addShortcutKeys: {
"bold": "ctrl+66", //bold
"italic": "ctrl+73" //italic
"bold": "ctrl+b", //bold
"italic": "ctrl+i" //italic
},
"events": {
"beforeRenderNode": function ( e ) {
......
......@@ -138,8 +138,8 @@ KityMinder.registerModule( "HistoryModule", function () {
} )
},
addShortcutKeys: {
"Undo": "ctrl+90", //undo
"Redo": "ctrl+89" //redo
"Undo": "ctrl+z", //undo
"Redo": "ctrl+y" //redo
},
"events": {
"saveScene": function ( e ) {
......
......@@ -62,7 +62,7 @@ KityMinder.registerModule( 'Zoom', function () {
'zoom-out': ZoomOutCommand
},
addShortcutKeys: {
"zoom-in": "+", //=
"zoom-in": "=", //=
"zoom-out": "-" //-
},
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