Commit 2a52109c authored by Joel Collins's avatar Joel Collins
Browse files

Click-to-move checkbox now works

parent d3eb8bb7
Loading
Loading
Loading
Loading
+26 −21
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@

  <script>
    // TODO: Remember a position and restore that position
    // TODO: Right click to auto-focus, centered on that region

    // Key IDs
    var pgupKeyID = 33;
@@ -117,7 +118,9 @@

    // Methods for input events

    // Click-to-move
    function clickHotspotImage(event) {
      if (document.getElementById("clickPositionCheck").checked == true) {
        xCoordinate = event.offsetX;
        yCoordinate = event.offsetY;
        console.log(xCoordinate, yCoordinate)
@@ -129,6 +132,18 @@
        console.log(xSteps, ySteps, 0)
        moveStagePositions(xSteps, ySteps, 0)
      }
    }

    // Scroll-to-focus
    window.addEventListener('wheel', function(e) {
      multiplier = 1/100;
      z_delta = e.deltaY * multiplier * focusVelocity;
      console.log(z_delta);
      if (document.getElementById("scrollFocusCheck").checked == true) {
        // Make a position request
        safeRequest("POST", "{{ url_for('position') }}", { "absolute": false, "z": z_delta}, keyMoveCallback)
      }
    });

    addEventListener("keydown", function (e) {
        keysDown[e.keyCode] = true; //Add key to array
@@ -169,16 +184,6 @@
        delete keysDown[e.keyCode]; //Remove key from array
    }, false);
  
    window.addEventListener('wheel', function(e) {
      multiplier = 1/100;
      z_delta = e.deltaY * multiplier * focusVelocity;
      console.log(z_delta);
      if (document.getElementById("scrollFocusCheck").checked == true) {
        // Make a position request
        safeRequest("POST", "{{ url_for('position') }}", { "absolute": false, "z": z_delta}, keyMoveCallback)
      }
    });
  
    // Methods for making requests
    function safeRequest(method, url, payload, callback) {
      if (requestLock == false) {