Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right Click causes MoveCanvasAction #258

Closed
brian-eightsolutions opened this issue Jul 10, 2018 · 3 comments
Closed

Right Click causes MoveCanvasAction #258

brian-eightsolutions opened this issue Jul 10, 2018 · 3 comments

Comments

@brian-eightsolutions
Copy link
Contributor

If you right click on the canvas and bring up the context menu, a MoveCanvasAction is fired by startFiringAction. But if you close the context menu by clicking on the context menu itself, stopFiringAction is not called. This causes a state where the canvas moves with the mouse without clicking anything until the mouse is clicked again.

I don't think the MoveCanvasAction should be fired if it is a right click.

brian-eightsolutions added a commit to brian-eightsolutions/react-diagrams that referenced this issue Jul 10, 2018
This is the proposed fix for the issue that I just logged: projectstorm#258
@tosiek88
Copy link

Hi can you reopen this issue, I was trying to track DiagramWidget.tsx but this file is anymore in repository. Behavior is still same, after right click all Nodes are moved.
Where logic about onMouseDown have been moved?

@msaglietto
Copy link

Hey I got the same issue adding a contextual menu on the canvas on 6.2.0... maybe this is a regression issue

The mouse down was moved to:
https://github.com/projectstorm/react-diagrams/blob/master/packages/react-canvas-core/src/entities/canvas/CanvasWidget.tsx#L86
or can be added to
https://github.com/projectstorm/react-diagrams/blob/master/packages/react-canvas-core/src/core-actions/ActionEventBus.ts#L51

But I think better to be added on the move action but don't know where is that

@alexandernst
Copy link
Contributor

I fixed it with the following:

engine = createEngine();
engine.getStateMachine().pushState(new DiagramState());

and my DiagramState class:

import {
  SelectingState,
  State,
  Action,
  InputType,
  DragCanvasState,
} from '@projectstorm/react-canvas-core';

import {
  PortModel,
  DragNewLinkState,
  DragDiagramItemsState
} from '@projectstorm/react-diagrams-core';

export class DiagramState extends State {
  constructor() {
    super({
      name: 'default-diagrams'
    });
    this.childStates = [new SelectingState()];
    this.dragCanvas = new DragCanvasState();
    this.dragNewLink = new DragNewLinkState();
    this.dragItems = new DragDiagramItemsState();

    // determine what was clicked on
    this.registerAction(
      new Action({
        type: InputType.MOUSE_DOWN,
        fire: (event) => {
          if (event.event.button !== 0) {
            // we don't want to do anything on right-clicks
            return;
          } else {
            const element = this.engine.getActionEventBus().getModelForEvent(event);

            // the canvas was clicked on, transition to the dragging canvas state
            if (!element) {
                this.transitionWithEvent(this.dragCanvas, event);
            }
            // initiate dragging a new link
            else if (element instanceof PortModel) {
                this.transitionWithEvent(this.dragNewLink, event);
            }
            // move the items (and potentially link points)
            else {
                this.transitionWithEvent(this.dragItems, event);
            }
          }
        }
      })
    );
  }
}

StrongDonald added a commit to StrongDonald/react-diagrams that referenced this issue Jun 20, 2023
This is the proposed fix for the issue that I just logged: projectstorm/react-diagrams#258
dluoulb pushed a commit to dluoulb/hs7-react-diagrams that referenced this issue Jan 31, 2024
This is the proposed fix for the issue that I just logged: projectstorm/react-diagrams#258
bunnybumbum pushed a commit to bunnybumbum/diagram_next that referenced this issue Mar 19, 2024
This is the proposed fix for the issue that I just logged: projectstorm/react-diagrams#258
SmartCodiDev added a commit to SmartCodiDev/React-Diagrams that referenced this issue May 31, 2024
This is the proposed fix for the issue that I just logged: projectstorm/react-diagrams#258
RealDiligentDev added a commit to RealDiligentDev/react-diagrams that referenced this issue Jul 27, 2024
This is the proposed fix for the issue that I just logged: projectstorm/react-diagrams#258
golden-lucky-monkey added a commit to golden-lucky-monkey/react-diagrams that referenced this issue Jul 27, 2024
This is the proposed fix for the issue that I just logged: projectstorm/react-diagrams#258
s7evenv added a commit to s7evenv/valiant-freact-diagram that referenced this issue Aug 12, 2024
This is the proposed fix for the issue that I just logged: projectstorm/react-diagrams#258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants