add key move
This commit is contained in:
@@ -146,6 +146,13 @@ define(
|
||||
}
|
||||
});
|
||||
|
||||
render.keyCapture.on('keydown', function(e) {
|
||||
if (me.contextMenu.visible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
me.mode.keydown && me.mode.keydown.call(me, e);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@ define(
|
||||
x: size.width / 2,
|
||||
y: size.height / 2
|
||||
});
|
||||
this.setMode();
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,13 @@ define(
|
||||
var pathAdjust = require('graphics/pathAdjust');
|
||||
var lang = require('common/lang');
|
||||
|
||||
// 移动步频
|
||||
var stepMap = {
|
||||
'left': [-5, 0],
|
||||
'right': [5, 0],
|
||||
'up': [0, -5],
|
||||
'down': [0, 5]
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理右键菜单
|
||||
@@ -72,7 +79,7 @@ define(
|
||||
|
||||
refreshControlPoints.call(this);
|
||||
|
||||
this.currentPoint = null;
|
||||
this.currentPoint = this.currentPointReserved = null;
|
||||
this.fontLayer.refresh();
|
||||
}
|
||||
|
||||
@@ -178,19 +185,6 @@ define(
|
||||
|
||||
this.coverLayer.refresh();
|
||||
this.fontLayer.refresh();
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 拖动结束事件
|
||||
*/
|
||||
dragend: function(e) {
|
||||
|
||||
if(this.currentPoint) {
|
||||
this.currentPoint.style = this.currentPointReserved.style;
|
||||
this.currentPointReserved = null;
|
||||
this.currentPoint = null;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -233,11 +227,36 @@ define(
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 按住
|
||||
*/
|
||||
keydown: function(e) {
|
||||
// 移动
|
||||
if(stepMap[e.key] && this.currentPoint) {
|
||||
var step = stepMap[e.key];
|
||||
var current = this.currentPoint;
|
||||
var reserved = this.currentPointReserved;
|
||||
if (step[0]) {
|
||||
current.x += step[0];
|
||||
current.point.x += step[0];
|
||||
reserved.x += step[0];
|
||||
reserved.point.x += step[0];
|
||||
}
|
||||
if (step[1]) {
|
||||
current.y += step[1];
|
||||
current.point.y += step[1];
|
||||
reserved.y += step[1];
|
||||
reserved.point.y += step[1];
|
||||
}
|
||||
this.coverLayer.refresh();
|
||||
this.fontLayer.refresh();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 开始
|
||||
*/
|
||||
begin: function() {
|
||||
|
||||
var me = this;
|
||||
var coverLayer = this.coverLayer;
|
||||
coverLayer.options.fill = true;
|
||||
@@ -245,13 +264,11 @@ define(
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 结束
|
||||
*/
|
||||
end: function() {
|
||||
|
||||
this.currentPoint = this.currentPointReserved = null;
|
||||
this.coverLayer.options.fill = false;
|
||||
this.coverLayer.clearShapes();
|
||||
this.coverLayer.refresh();
|
||||
|
||||
@@ -16,6 +16,13 @@ define(
|
||||
var commandList = require('../menu/commandList');
|
||||
var POS_CUSOR = require('./cursor');
|
||||
|
||||
// 移动步频
|
||||
var stepMap = {
|
||||
'left': [-5, 0],
|
||||
'right': [5, 0],
|
||||
'up': [0, -5],
|
||||
'down': [0, 5]
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理右键菜单
|
||||
@@ -201,6 +208,16 @@ define(
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 按住
|
||||
*/
|
||||
keydown: function(e) {
|
||||
// 移动
|
||||
if(stepMap[e.key] && this.currentGroup) {
|
||||
this.currentGroup.move(stepMap[e.key][0], stepMap[e.key][1]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 开始模式
|
||||
*/
|
||||
|
||||
@@ -65,12 +65,12 @@ define(
|
||||
}
|
||||
|
||||
/**
|
||||
* 按下处理事件
|
||||
* 按下弹起事件
|
||||
*
|
||||
* @param {Object} e 事件参数
|
||||
*/
|
||||
function keydetect(keyEvent, e) {
|
||||
|
||||
|
||||
if(false === this.events['key' + Event]) {
|
||||
return;
|
||||
}
|
||||
@@ -84,7 +84,6 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 鼠标动作捕获器
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user