Merge remote branch 'origin/master'

This commit is contained in:
Jonathan Puckey 2011-06-21 14:54:53 +02:00
commit bda60f1f90

View file

@ -371,24 +371,24 @@ var View = this.View = Base.extend({
*/ */
onResize: null onResize: null
}, new function() { // Injection scope for mouse handlers }, new function() { // Injection scope for mouse handlers
var view, var tool,
tool,
timer, timer,
curPoint, curPoint,
dragging = false; dragging = false;
function viewToArtwork(event) { function viewToArtwork(view, event) {
return view.viewToArtwork(DomEvent.getOffset(event, view._canvas)); return view.viewToArtwork(DomEvent.getOffset(event, view._canvas));
} }
function mousemove(event) { function mousemove(event) {
var view = View.focused;
if (!view || !(tool = view._scope.tool)) if (!view || !(tool = view._scope.tool))
return; return;
// If the event was triggered by a touch screen device, prevent the // If the event was triggered by a touch screen device, prevent the
// default behaviour, as it will otherwise scroll the page: // default behaviour, as it will otherwise scroll the page:
if (event && event.targetTouches) if (event && event.targetTouches)
DomEvent.preventDefault(event); DomEvent.preventDefault(event);
var point = event && viewToArtwork(event); var point = event && viewToArtwork(view, event);
var onlyMove = !!(!tool.onMouseDrag && tool.onMouseMove); var onlyMove = !!(!tool.onMouseDrag && tool.onMouseMove);
if (dragging && !onlyMove) { if (dragging && !onlyMove) {
curPoint = point || curPoint; curPoint = point || curPoint;
@ -403,6 +403,7 @@ var View = this.View = Base.extend({
} }
function mouseup(event) { function mouseup(event) {
var view = View.focused;
if (!view || !dragging) if (!view || !dragging)
return; return;
dragging = false; dragging = false;
@ -410,7 +411,7 @@ var View = this.View = Base.extend({
if (tool) { if (tool) {
if (timer != null) if (timer != null)
timer = clearInterval(timer); timer = clearInterval(timer);
if (tool.onHandleEvent('mouseup', viewToArtwork(event), event)) if (tool.onHandleEvent('mouseup', viewToArtwork(view, event), event))
view.draw(true); view.draw(true);
} }
} }
@ -437,14 +438,14 @@ var View = this.View = Base.extend({
return { return {
_createEvents: function() { _createEvents: function() {
var that = this; var view = this;
function mousedown(event) { function mousedown(event) {
// Tell the Key class which view should receive keyboard input. // Tell the Key class which view should receive keyboard input.
view = View.focused = that; View.focused = view;
if (!(tool = view._scope.tool)) if (!(tool = view._scope.tool))
return; return;
curPoint = viewToArtwork(event); curPoint = viewToArtwork(view, event);
if (tool.onHandleEvent('mousedown', curPoint, event)) if (tool.onHandleEvent('mousedown', curPoint, event))
view.draw(true); view.draw(true);
if (tool.eventInterval != null) if (tool.eventInterval != null)