Add support for Tool scripts in PaperScript.

This commit is contained in:
Jürg Lehni 2011-03-04 01:05:23 +00:00
parent b80ba6fc86
commit be0d260cb4

View file

@ -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;
}
}