Issue #215 : Dev environment : support keyboard/undo/redo events in drawing tests

This commit is contained in:
jdescottes
2015-08-24 23:56:09 +02:00
parent ff98670055
commit 754bc9b830
10 changed files with 59 additions and 9 deletions

View File

@@ -9,6 +9,7 @@
ns.DrawingTestRecorder.prototype.init = function () {
$.subscribe(Events.MOUSE_EVENT, this.onMouseEvent_.bind(this));
$.subscribe(Events.KEYBOARD_EVENT, this.onKeyboardEvent_.bind(this));
$.subscribe(Events.TOOL_SELECTED, this.onToolEvent_.bind(this));
$.subscribe(Events.PRIMARY_COLOR_SELECTED, this.onColorEvent_.bind(this, true));
$.subscribe(Events.SECONDARY_COLOR_SELECTED, this.onColorEvent_.bind(this, false));
@@ -73,6 +74,23 @@
}
};
ns.DrawingTestRecorder.prototype.onKeyboardEvent_ = function (evt, keyboardEvent) {
if (this.isRecording) {
var recordEvent = {};
recordEvent.type = 'keyboard-event';
recordEvent.event = {
which : keyboardEvent.which,
shiftKey : keyboardEvent.shiftKey,
altKey : keyboardEvent.altKey,
ctrlKey : keyboardEvent.ctrlKey,
target : {
nodeName : keyboardEvent.target.nodeName
}
};
this.events.push(recordEvent);
}
};
ns.DrawingTestRecorder.prototype.onColorEvent_ = function (isPrimary, evt, color) {
if (this.isRecording) {
var recordEvent = {};