mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Test code for tool handlers and only create tool if they are present.
This commit is contained in:
parent
c86eaf5684
commit
453da21bab
1 changed files with 11 additions and 11 deletions
|
@ -119,18 +119,18 @@ var PaperScript = new function() {
|
||||||
// Use paper.extend() to create a paper scope within which the code is
|
// Use paper.extend() to create a paper scope within which the code is
|
||||||
// evaluated.
|
// evaluated.
|
||||||
with (paper.extend()) {
|
with (paper.extend()) {
|
||||||
// TODO: Only create tool if code contains reference to tool scripts!
|
var tool = /onMouse(?:Up|Down|Move|Drag)/.test(code) && new Tool();
|
||||||
var tool = new Tool();
|
|
||||||
var res = eval(compile(code));
|
var res = eval(compile(code));
|
||||||
// TODO: Again, only do this if we actually detected a tool script:
|
if (tool) {
|
||||||
Base.each(['onEditOptions', 'onOptions', 'onSelect', 'onDeselect',
|
Base.each(['onEditOptions', 'onOptions', 'onSelect',
|
||||||
'onReselect', 'onMouseDown', 'onMouseUp', 'onMouseDrag',
|
'onDeselect', 'onReselect', 'onMouseDown', 'onMouseUp',
|
||||||
'onMouseMove'], function(key) {
|
'onMouseDrag', 'onMouseMove'], function(key) {
|
||||||
try {
|
try {
|
||||||
tool[key] = eval(key);
|
tool[key] = eval(key);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue