Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Commit

Permalink
Reset the browser selection on drag end
Browse files Browse the repository at this point in the history
A drag end will consume the corresponding mouse up operation, meaning
the window selection is not cleared. Cope with this by listening for
the drag event and clearing the selection.
  • Loading branch information
peitschie committed Dec 5, 2013
1 parent a5173ea commit f56f474
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions webodf/lib/gui/SessionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,17 @@ gui.SessionController = (function () {
isMouseMoved = false;
}

function handleDragEnd() {
// Drag operations consume the corresponding mouse up event.
// If this happens, the selection should still be reset.
if (clickStartedWithinContainer) {
eventManager.focus();
}
clickCount = 0;
clickStartedWithinContainer = false;
isMouseMoved = false;
}

function handleContextMenu(e) {
// TODO Various browsers have different default behaviours on right click
// We can detect this at runtime without doing any kind of platform sniffing
Expand Down Expand Up @@ -1023,6 +1034,7 @@ gui.SessionController = (function () {
eventManager.subscribe("mousemove", drawShadowCursorTask.trigger);
eventManager.subscribe("mouseup", handleMouseUp);
eventManager.subscribe("contextmenu", handleContextMenu);
eventManager.subscribe("dragend", handleDragEnd);

// start maintaining the cursor selection now
odtDocument.subscribe(ops.OdtDocument.signalOperationExecuted, redrawRegionSelectionTask.trigger);
Expand Down Expand Up @@ -1067,6 +1079,7 @@ gui.SessionController = (function () {
eventManager.unsubscribe("mousedown", handleMouseDown);
eventManager.unsubscribe("mouseup", handleMouseUp);
eventManager.unsubscribe("contextmenu", handleContextMenu);
eventManager.unsubscribe("dragend", handleDragEnd);
odtDocument.getOdfCanvas().getElement().classList.remove("virtualSelections");
};

Expand Down

0 comments on commit f56f474

Please sign in to comment.