mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Add support for Tool scripts in PaperScript.
This commit is contained in:
parent
b80ba6fc86
commit
be0d260cb4
1 changed files with 13 additions and 1 deletions
|
@ -119,7 +119,19 @@ var PaperScript = new function() {
|
|||
// Use paper.extend() to create a paper scope within which the code is
|
||||
// evaluated.
|
||||
with (paper.extend()) {
|
||||
return eval(compile(code));
|
||||
// TODO: Only create tool if code contains reference to tool scripts!
|
||||
var tool = 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) {
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue