mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Make preventDefault() work on IE too.
This commit is contained in:
parent
ae3ec6f2d7
commit
ccbdb2abe3
1 changed files with 11 additions and 5 deletions
|
@ -42,7 +42,8 @@ var Key = new function() {
|
||||||
// Call the onKeyDown or onKeyUp handler if present:
|
// Call the onKeyDown or onKeyUp handler if present:
|
||||||
// TODO: don't call the key handler if the key is a modifier?
|
// TODO: don't call the key handler if the key is a modifier?
|
||||||
if (paper.tool[toolHandler]) {
|
if (paper.tool[toolHandler]) {
|
||||||
var preventDefault = paper.tool[toolHandler]({
|
// TODO: Introduce a class for this?
|
||||||
|
var keyEvent = {
|
||||||
type: keyDown ? 'key-down' : 'key-up',
|
type: keyDown ? 'key-down' : 'key-up',
|
||||||
keyCode: code,
|
keyCode: code,
|
||||||
character: key,
|
character: key,
|
||||||
|
@ -52,14 +53,19 @@ var Key = new function() {
|
||||||
// it into a function.
|
// it into a function.
|
||||||
// TODO: Port to Scriptographer:
|
// TODO: Port to Scriptographer:
|
||||||
preventDefault: function() {
|
preventDefault: function() {
|
||||||
event.preventDefault()
|
if (event.preventDefault) {
|
||||||
|
event.preventDefault();
|
||||||
|
} else {
|
||||||
|
event.returnValue = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
var res = paper.tool[toolHandler](keyEvent);
|
||||||
// TODO: Port to Scriptographer:
|
// TODO: Port to Scriptographer:
|
||||||
// When the handler function returns false, prevent the
|
// When the handler function returns false, prevent the
|
||||||
// default behaviour of the key event:
|
// default behaviour of the key event:
|
||||||
if (preventDefault === false)
|
if (res === false)
|
||||||
event.preventDefault();
|
keyEvent.preventDefault();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, {});
|
}, {});
|
||||||
|
|
Loading…
Reference in a new issue