Commit 6acbbdf4 authored by Akikonata's avatar Akikonata

fixed conflict

parents a87ee4c9 7fcb5d76
...@@ -21,7 +21,9 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -21,7 +21,9 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._initEvents(); this._initEvents();
this._initMinder(); this._initMinder();
this._initSelection(); this._initSelection();
this._initShortcutKey();
this._initModules(); this._initModules();
this.fire( 'ready' ); this.fire( 'ready' );
}, },
getOptions: function ( key ) { getOptions: function ( key ) {
...@@ -77,6 +79,47 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -77,6 +79,47 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
}, },
getRenderTarget: function () { getRenderTarget: function () {
return this._renderTarget; return this._renderTarget;
},
_initShortcutKey:function(){
this._shortcutkeys = {};
this._bindshortcutKeys();
},
addShortcutKeys: function (cmd, keys) {
var obj = {};
if (keys) {
obj[cmd] = keys
} else {
obj = cmd;
}
utils.extend(this._shortcutkeys, obj)
},
_bindshortcutKeys: function () {
var me = this, shortcutkeys = this._shortcutkeys;
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();
}
}
}
}
});
} }
} ); } );
......
...@@ -39,6 +39,11 @@ kity.extendClass( Minder, { ...@@ -39,6 +39,11 @@ kity.extendClass( Minder, {
} }
} }
//添加模块的快捷键
if(moduleDeals.addShortcutKeys){
this.addShortcutKeys(moduleDeals.addShortcutKeys)
}
} }
}, },
......
...@@ -103,7 +103,10 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -103,7 +103,10 @@ KityMinder.registerModule( "HistoryModule", function () {
queryState: function ( km ) { queryState: function ( km ) {
km.historyManager.hasUndo ? 0 : -1; km.historyManager.hasUndo ? 0 : -1;
}, },
isNeedUndo: true
isNeedUndo: function () {
return false;
}
} ), } ),
"redo": kity.createClass( "RedoCommand", { "redo": kity.createClass( "RedoCommand", {
base: Command, base: Command,
...@@ -115,10 +118,15 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -115,10 +118,15 @@ KityMinder.registerModule( "HistoryModule", function () {
queryState: function ( km ) { queryState: function ( km ) {
return km.historyManager.hasRedo ? 0 : -1; return km.historyManager.hasRedo ? 0 : -1;
}, },
isNeedUndo: true isNeedUndo: function () {
return false;
}
} ) } )
}, },
addShortcutKeys: {
"Undo": "ctrl+90", //undo
"Redo": "ctrl+89" //redo
},
"events": { "events": {
"saveScene": function ( e ) { "saveScene": function ( e ) {
this.historyManager.saveScene(); this.historyManager.saveScene();
......
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