Skip to content

Commit

Permalink
Fix middle-click being blocked by resize-tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Aug 15, 2017
1 parent 600b047 commit 39198b2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ canvasDiv.addEventListener('mousedown', ev => {
let newHand = displayed.get().hand.withPos(eventPosRelativeTo(ev, canvas));
let newInspector = syncArea(displayed.get()).
withHand(newHand).
afterGrabbing(false, false). // Grab the gate.
afterGrabbing(false, false, true). // Grab the gate.
withHand(newHand). // Lose the gate.
afterTidyingUp().
withJustEnoughWires(newHand, 0);
Expand Down
15 changes: 13 additions & 2 deletions src/ui/DisplayedCircuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,13 +948,24 @@ class DisplayedCircuit {
* @param {!Hand} hand
* @param {!boolean=false} duplicate
* @param {!boolean=false} wholeColumn
* @param {!boolean=false} ignoreResizeTabs
* @returns {!{newCircuit: !DisplayedCircuit, newHand: !Hand}}
*/
tryGrab(hand, duplicate=false, wholeColumn=false) {
tryGrab(hand, duplicate=false, wholeColumn=false, ignoreResizeTabs=false) {
if (wholeColumn) {
return this._tryGrabWholeColumn(hand, duplicate) || {newCircuit: this, newHand: hand};
}
let {newCircuit, newHand} = this._tryGrabResizeTab(hand) || {newCircuit: this, newHand: hand};

let newHand = hand;
let newCircuit = this;
if (!ignoreResizeTabs) {
let resizing = this._tryGrabResizeTab(hand);
if (resizing !== undefined) {
newHand = resizing.newHand;
newCircuit = resizing.newCircuit;
}
}

return newCircuit._tryGrabGate(newHand, duplicate) || {newCircuit, newHand};
}

Expand Down
5 changes: 3 additions & 2 deletions src/ui/DisplayedInspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,16 @@ class DisplayedInspector {
/**
* @param {!boolean=false} duplicate
* @param {!boolean=false} wholeCol
* @param {!boolean=false} ignoreResizeTabs
* @returns {!DisplayedInspector}
*/
afterGrabbing(duplicate=false, wholeCol=false) {
afterGrabbing(duplicate=false, wholeCol=false, ignoreResizeTabs=false) {
let hand = this.hand;
let circuit = this.displayedCircuit;

hand = this.displayedToolboxTop.tryGrab(hand);
hand = this.displayedToolboxBottom.tryGrab(hand);
let obj = circuit.tryGrab(hand, duplicate, wholeCol);
let obj = circuit.tryGrab(hand, duplicate, wholeCol, ignoreResizeTabs);
hand = obj.newHand;
circuit = obj.newCircuit;

Expand Down

0 comments on commit 39198b2

Please sign in to comment.