Skip to content

Commit

Permalink
allow mousedown/click on edited node, fixes ondras#59
Browse files Browse the repository at this point in the history
  • Loading branch information
ondras committed Aug 2, 2015
1 parent 1bc753c commit 9957e26
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions my-mind.js
Original file line number Diff line number Diff line change
Expand Up @@ -4780,6 +4780,7 @@ MM.Mouse.handleEvent = function(e) {
switch (e.type) {
case "click":
var item = MM.App.map.getItemFor(e.target);
if (MM.App.editing && item == MM.App.current) { return; } /* ignore on edited node */
if (item) { MM.App.select(item); }
break;

Expand All @@ -4803,21 +4804,21 @@ MM.Mouse.handleEvent = function(e) {
e.clientX = e.touches[0].clientX;
e.clientY = e.touches[0].clientY;
case "mousedown":
if (e.type == "mousedown") { e.preventDefault(); } /* to prevent blurring the clipboard node */
var item = MM.App.map.getItemFor(e.target);
if (MM.App.editing) {
if (item == MM.App.current) { return; } /* ignore dnd on edited node */
MM.Command.Finish.execute(); /* clicked elsewhere => finalize edit */
}

if (e.type == "mousedown") { e.preventDefault(); } /* to prevent blurring the clipboard node */

if (e.type == "touchstart") { /* context menu here, after we have the item */
this._touchTimeout = setTimeout(function() {
item && MM.App.select(item);
MM.Menu.open(e.clientX, e.clientY);
}, this.TOUCH_DELAY);
}

if (MM.App.editing) {
if (item == MM.App.current) { return; } /* ignore dnd on edited node */
MM.Command.Finish.execute(); /* clicked elsewhere => finalize edit */
}

this._startDrag(e, item);
break;

Expand Down
13 changes: 7 additions & 6 deletions src/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ MM.Mouse.handleEvent = function(e) {
switch (e.type) {
case "click":
var item = MM.App.map.getItemFor(e.target);
if (MM.App.editing && item == MM.App.current) { return; } /* ignore on edited node */
if (item) { MM.App.select(item); }
break;

Expand All @@ -48,21 +49,21 @@ MM.Mouse.handleEvent = function(e) {
e.clientX = e.touches[0].clientX;
e.clientY = e.touches[0].clientY;
case "mousedown":
if (e.type == "mousedown") { e.preventDefault(); } /* to prevent blurring the clipboard node */
var item = MM.App.map.getItemFor(e.target);
if (MM.App.editing) {
if (item == MM.App.current) { return; } /* ignore dnd on edited node */
MM.Command.Finish.execute(); /* clicked elsewhere => finalize edit */
}

if (e.type == "mousedown") { e.preventDefault(); } /* to prevent blurring the clipboard node */

if (e.type == "touchstart") { /* context menu here, after we have the item */
this._touchTimeout = setTimeout(function() {
item && MM.App.select(item);
MM.Menu.open(e.clientX, e.clientY);
}, this.TOUCH_DELAY);
}

if (MM.App.editing) {
if (item == MM.App.current) { return; } /* ignore dnd on edited node */
MM.Command.Finish.execute(); /* clicked elsewhere => finalize edit */
}

this._startDrag(e, item);
break;

Expand Down

0 comments on commit 9957e26

Please sign in to comment.