mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -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
|
||||
// evaluated.
|
||||
with (paper.extend()) {
|
||||
// TODO: Only create tool if code contains reference to tool scripts!
|
||||
var tool = new Tool();
|
||||
var tool = /onMouse(?:Up|Down|Move|Drag)/.test(code) && new Tool();
|
||||
var res = eval(compile(code));
|
||||
// TODO: Again, only do this if we actually detected a tool script:
|
||||
Base.each(['onEditOptions', 'onOptions', 'onSelect', 'onDeselect',
|
||||
'onReselect', 'onMouseDown', 'onMouseUp', 'onMouseDrag',
|
||||
'onMouseMove'], function(key) {
|
||||
try {
|
||||
tool[key] = eval(key);
|
||||
} catch (e) {
|
||||
}
|
||||
});
|
||||
if (tool) {
|
||||
Base.each(['onEditOptions', 'onOptions', 'onSelect',
|
||||
'onDeselect', 'onReselect', 'onMouseDown', 'onMouseUp',
|
||||
'onMouseDrag', 'onMouseMove'], function(key) {
|
||||
try {
|
||||
tool[key] = eval(key);
|
||||
} catch (e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue