blurymind / YarnClassic

A tool for writing interactive dialogue in games!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Align nodes does not work on MacOS

pjarnfelt opened this issue · comments

Problem: Pressing the Align nodes says "Select nodes to align" even when having nodes selected.

App version: 0.4.44 standalone MacOS

Steps to reproduce:
Select nodes and press any align button.

align1
align2

commented

I'm having the same problem on Windows.

Pressing Horizontal and Vertical Align deselects my nodes and brings up the "Select nodes to align" prompt.
Spiral and Alphabetical Align simply deselects the nodes without the prompt.

App version: 0.4.60

Wow this was a problem way back in June? What's essentially happening is it's being deselected before any of the align functions can act on the selected nodes. This is happening in two places and they are both in the input.js file in the this.trackMouseEvents function.

this.trackMouseEvents = function() {
    $(document).on('pointerdown', e => {
      self.isDragging = e.target.className === 'nodes';
      self.mouse.x = e.pageX;
      self.mouse.y = e.pageY;

      self.isMiddleButtonDown = (e.button === MouseButton.Middle);
      this.isLeftButtonDown = (e.button === MouseButton.Left);
      
      if (app.inWorkspace()) {
        if (!e.altKey && !e.shiftKey)
          app.workspace.deselectAll(); // BEING DESELECTED HERE


        switch (e.button) {
        case MouseButton.Left:
            app.workspace.onMarqueeStart({ x: e.pageX, y: e.pageY }); // THIS LINE STARTS LOGIC THAT RUNS onMarqueeEnd WHICH DESELECTS THE NODES IF THE MARQUEE LENGTH IS 0
          break;

        case MouseButton.Middle:
          app.workspace.onDragStart({ x: e.pageX, y: e.pageY });
          break;
        }
      } else if (app.inEditor() && e.button === MouseButton.Right) {
        app.guessPopUpHelper();
        e.preventDefault();
      }
    });

The fix for the MouseButton.Left case is:

case MouseButton.Left:
  if (self.isDragging) {
    app.workspace.onMarqueeStart({ x: e.pageX, y: e.pageY });
  }
  break;

This way the Marquee doesn't actually detect start a drag which doesn't lead to a deselection down the line in this.onMarqueeEnd in the workspace.js file when self.marqueeSelection.length == 0 when you are just clicking the mouse up and down.

The fix for the first is maybe just to comment the if (!e.altKey && !e.shiftKey) line out? I'm not really sure what this is used for but I found that functionality for selecting stuff didn't change if this was removed. Not sure what the purpose of this is.

I'm not very great in Javascript, so if there are better fixes I would love to see them.