Skip to content

Commit

Permalink
Better detect code that requires a tool object.
Browse files Browse the repository at this point in the history
  • Loading branch information
lehni committed Feb 14, 2016
1 parent 27197bd commit dbd7a90
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/core/PaperScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,10 @@ Base.exports.PaperScript = (function() {
// Set currently active scope.
paper = scope;
var view = scope.getView(),
// Only create a tool object if something resembling a tool handler
// definition is contained in the code.
tool = /\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b/.test(code)
? new Tool()
: null,
// Only create a tool if the tool object is accessed or something
// resembling a global tool handler is contained in the code.
tool = /\btool\.\w+|\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b/
.test(code) ? new Tool() : null,
toolHandlers = tool ? tool._events : [],
// Compile a list of all handlers that can be defined globally
// inside the PaperScript. These are passed on to the function as
Expand Down

0 comments on commit dbd7a90

Please sign in to comment.