mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Events: paper namespace may not be initialized when key evens are emitted.
This commit is contained in:
parent
1c4ff31e6c
commit
b2f3b587ec
1 changed files with 3 additions and 3 deletions
|
@ -67,7 +67,7 @@ var Key = new function() {
|
||||||
// based on whichever key is used for commands.
|
// based on whichever key is used for commands.
|
||||||
command: {
|
command: {
|
||||||
get: function() {
|
get: function() {
|
||||||
var agent = paper.agent;
|
var agent = paper && paper.agent;
|
||||||
return agent && agent.mac ? this.meta : this.control;
|
return agent && agent.mac ? this.meta : this.control;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ var Key = new function() {
|
||||||
// Detect modifiers and mark them as pressed / released
|
// Detect modifiers and mark them as pressed / released
|
||||||
if (key.length > 1 && (name = Base.camelize(key)) in modifiers) {
|
if (key.length > 1 && (name = Base.camelize(key)) in modifiers) {
|
||||||
modifiers[name] = down;
|
modifiers[name] = down;
|
||||||
var agent = paper.agent;
|
var agent = paper && paper.agent;
|
||||||
if (name === 'meta' && agent && agent.mac) {
|
if (name === 'meta' && agent && agent.mac) {
|
||||||
// Fix a strange behavior on Mac where no keyup events are
|
// Fix a strange behavior on Mac where no keyup events are
|
||||||
// received for any keys pressed while the meta key is down.
|
// received for any keys pressed while the meta key is down.
|
||||||
|
@ -136,7 +136,7 @@ var Key = new function() {
|
||||||
DomEvent.add(document, {
|
DomEvent.add(document, {
|
||||||
keydown: function(event) {
|
keydown: function(event) {
|
||||||
var key = getKey(event),
|
var key = getKey(event),
|
||||||
agent = paper.agent;
|
agent = paper && paper.agent;
|
||||||
// Directly handle any special keys (key.length > 1) in keydown, as
|
// Directly handle any special keys (key.length > 1) in keydown, as
|
||||||
// not all of them will receive keypress events.
|
// not all of them will receive keypress events.
|
||||||
// Chrome doesn't fire keypress events for command and alt keys,
|
// Chrome doesn't fire keypress events for command and alt keys,
|
||||||
|
|
Loading…
Reference in a new issue