paperjs/paper.js — Issue #64: Feature: Add double click _or_ make DomEvent public
Author: benogle
Created: 2011-12-10 02:41:04+00:00
State: open

I need double click functionality. This is fairly easy to add by overriding/monkey patching the `View._createEvents` fn, then the `Tool.onHandleEvent` function:

```
var oldViewCreateEvents = paper.View.prototype._createEvents;
paper.View.prototype._createEvents = function() {
var obj = oldViewCreateEvents.call(this);
var view = this;

obj.dblclick = function(event) {
View._focused = view;
if (!(tool = view._scope.tool))
return;
var curPoint = view.viewToProject(DomEvent.getOffset(event, view._canvas));
if (tool.onHandleEvent('dblclick', curPoint, event))
view.draw(true);
}

return obj;
};
```

and tool event: (proper override in coffeescript)

```
onHandleEvent: (type, pt, event) =>
called = false
if type == 'dblclick'
#this.updateEvent(type, pt, null, null, true, false, false);
if this.onDblClick
this.onDblClick(new ToolEvent(this, type, event))
called = true
else
called = super(type, pt, event)
called
```

The issue is that DomEvent is not public. The handler up there needs it for the `getOffset` function, which is complicated enough I'd rather not duplicate it in my code.

Is this something you guys would consider? I can write the addition to paper if it would be accepted, but making DomEvent public would make me happy as well.