Paperscript#run: keep tool on global the paper object.

This commit is contained in:
Jonathan Puckey 2011-03-09 19:33:53 +01:00
parent c7cefcba3a
commit fed52bd521

View file

@ -131,14 +131,14 @@ var PaperScript = new function() {
function run(code) {
with (paper) {
var tool = /onMouse(?:Up|Down|Move|Drag)/.test(code) && new Tool();
paper.tool = /onMouse(?:Up|Down|Move|Drag)/.test(code) && new Tool();
var res = eval(compile(code));
if (tool) {
if (paper.tool) {
Base.each(['onEditOptions', 'onOptions', 'onSelect',
'onDeselect', 'onReselect', 'onMouseDown', 'onMouseUp',
'onMouseDrag', 'onMouseMove'], function(key) {
try {
tool[key] = eval(key);
paper.tool[key] = eval(key);
} catch (e) {
}
});