diff -r bd58970ffd16 -r b43dd87f7ffa client/js/paper-renderer.js --- a/client/js/paper-renderer.js Fri Aug 17 12:50:00 2012 +0200 +++ b/client/js/paper-renderer.js Fri Aug 17 18:36:12 2012 +0200 @@ -380,7 +380,8 @@ Rkns.Renderer.TempEdge.prototype.paperShift = function(_delta) { this.end_pos = this.end_pos.add(_delta); - this._renderer.onMouseMove({point: this.end_pos}); + var _hitResult = paper.project.hitTest(this.end_pos); + this._renderer.findTarget(_hitResult); this.redraw(); } @@ -779,15 +780,18 @@ _tool.onMouseDrag = function(_event) { _this.onMouseDrag(_event); } - _tool.onMouseUp = function(_event) { + this.canvas_$.mouseup(function(_event) { _this.onMouseUp(_event); - } + }); this.canvas_$.mousewheel(function(_event, _delta) { _this.onScroll(_event, _delta); - }) + }); this.canvas_$.dblclick(function(_event) { _this.onDoubleClick(_event); }); + this.canvas_$.mouseenter(function(_event) { + _this.onMouseEnter(_event); + }); this.editor_$.find(".Rk-ZoomOut").click(function() { _this.offset = new paper.Point([ _this.canvas_$.width(), @@ -882,8 +886,7 @@ this.click_target = _tmpEdge; } -Rkns.Renderer.Scene.prototype.onMouseMove = function(_event) { - var _hitResult = paper.project.hitTest(_event.point); +Rkns.Renderer.Scene.prototype.findTarget = function(_hitResult) { if (_hitResult && typeof _hitResult.item.__controller !== "undefined") { var _newTarget = _hitResult.item.__controller; if (this.selected_target !== _hitResult.item.__controller) { @@ -901,6 +904,20 @@ } } +Rkns.Renderer.Scene.prototype.onMouseMove = function(_event) { + var _hitResult = paper.project.hitTest(_event.point); + if (this.is_dragging) { + if (this.click_target && typeof this.click_target.paperShift === "function") { + this.click_target.paperShift(_event.delta); + } else { + this.offset = this.offset.add(_event.delta); + this.redraw(); + } + } else { + this.findTarget(_hitResult); + } +} + Rkns.Renderer.Scene.prototype.onMouseDown = function(_event) { this.is_dragging = false; var _hitResult = paper.project.hitTest(_event.point); @@ -919,17 +936,20 @@ Rkns.Renderer.Scene.prototype.onMouseDrag = function(_event) { this.is_dragging = true; - if (this.click_target && typeof this.click_target.paperShift === "function") { - this.click_target.paperShift(_event.delta); - } else { - this.offset = this.offset.add(_event.delta); - this.redraw(); - } + this.onMouseMove(_event); } Rkns.Renderer.Scene.prototype.onMouseUp = function(_event) { if (this.click_target) { - this.click_target.mouseup(_event); + var _off = this.canvas_$.offset(); + this.click_target.mouseup( + { + point: new paper.Point([ + _event.pageX - _off.left, + _event.pageY - _off.top + ]) + } + ); } this.is_dragging = false; this.click_target = null; @@ -974,3 +994,26 @@ } paper.view.draw(); } + +Rkns.Renderer.Scene.prototype.onMouseEnter = function(_event) { + var _newEl = this.renkan.selected_bin_item; + if (_newEl) { + var _off = this.canvas_$.offset(), + _point = new paper.Point([ + _event.pageX - _off.left, + _event.pageY - _off.top + ]), + _coords = this.toModelCoords(_point), + _node = this._project.addNode({ + uri: _newEl.uri, + title: _newEl.title, + description: _newEl.description, + position: { + x: _coords.x, + y: _coords.y + } + }, Rkns._RENDER_AND_SAVE); + this.is_dragging = true; + this.click_target = _node.__controller; + } +} \ No newline at end of file