2011-02-08 13:15:55 +01:00
|
|
|
Tool = ToolHandler.extend({
|
2011-02-11 14:40:36 +01:00
|
|
|
beans: true,
|
2011-02-13 18:52:17 +00:00
|
|
|
|
2011-02-08 13:15:55 +01:00
|
|
|
initialize: function(handlers, doc) {
|
|
|
|
this.base(handlers);
|
|
|
|
},
|
|
|
|
|
|
|
|
setDocument: function(doc) {
|
2011-02-11 14:40:36 +01:00
|
|
|
this._document = doc;
|
2011-02-08 13:15:55 +01:00
|
|
|
var that = this;
|
|
|
|
$(doc.canvas).addEvents({
|
|
|
|
mousedown: function(e) {
|
|
|
|
that.onHandleEvent('MOUSE_DOWN', new Point(e.offset), null, null);
|
2011-02-11 14:40:36 +01:00
|
|
|
that._document.redraw();
|
2011-02-08 13:15:55 +01:00
|
|
|
},
|
|
|
|
drag: function(e) {
|
|
|
|
that.onHandleEvent('MOUSE_DRAG', new Point(e.offset), null, null);
|
2011-02-11 14:40:36 +01:00
|
|
|
that._document.redraw();
|
2011-02-08 13:15:55 +01:00
|
|
|
},
|
|
|
|
mouseup: function(e) {
|
|
|
|
that.onHandleEvent('MOUSE_UP', new Point(e.offset), null, null);
|
2011-02-11 14:40:36 +01:00
|
|
|
that._document.redraw();
|
2011-02-08 13:15:55 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2011-02-11 14:40:36 +01:00
|
|
|
* The fixed time delay between each call to the {@link #onMouseDrag}
|
2011-02-08 13:15:55 +01:00
|
|
|
* event. Setting this to an interval means the {@link #onMouseDrag} event
|
|
|
|
* is called repeatedly after the initial {@link #onMouseDown} until the
|
|
|
|
* user releases the mouse.
|
|
|
|
*
|
|
|
|
* Sample code:
|
|
|
|
* <code>
|
|
|
|
* // Fire the onMouseDrag event once a second,
|
|
|
|
* // while the mouse button is down
|
|
|
|
* tool.eventInterval = 1000;
|
|
|
|
* </code>
|
|
|
|
*
|
|
|
|
* @return the interval time in milliseconds
|
|
|
|
*/
|
2011-02-11 14:40:36 +01:00
|
|
|
eventInterval: -1,
|
2011-02-08 13:15:55 +01:00
|
|
|
|
2011-02-11 14:40:36 +01:00
|
|
|
getDocument: function() {
|
|
|
|
return this._document;
|
2011-02-08 13:15:55 +01:00
|
|
|
}
|
2011-02-13 16:26:24 +00:00
|
|
|
});
|