Turn off canvas dragging with left click and mouse movement #1385
-
Hey there, I have a prototype running using GLSP node server along with the GLSP VSCode integration (loosely based on a mix of the task and workflow examples). I've noticed that holding down the left mouse button and moving the mouse, moves the canvas. Which is definitely nice. However, I've found that this can cause some problems when you are trying to connect links between nodes. If you click on a node after clicking the link item in the palette and then click on the target node either too fast or your hand moves at all, it no longer thinks you are selecting the target node for the link. Is there anyway to turn this feature off? Be that all together or via a preference. Cheers |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi Jonathan, So if you want to get rid of the canvas moving altogether, you need to replace the current mouse listener with one that does nothing on drag using a module, i.e., something like this: export const customModule = new FeatureModule((_bind, _unbind, _isBound, rebind) => {
rebind(GLSPScrollMouseListener).to(MyScrollMouseListener);
});
@injectable()
export class MyScrollMouseListener extends GLSPScrollMouseListener {
protected override dragCanvas(model: GModelRoot & Viewport, event: MouseEvent, lastScrollPosition: Point): Action[] {
// do not drag canvas
return [];
}
} That module needs to be integrated in the container creation of your class WorkflowGLSPStarter extends GLSPStarter {
createContainer(...containerConfiguration: ContainerConfiguration): Container {
return createWorkflowDiagramContainer(...containerConfiguration, { replace: myEdgeCreationToolModule });
}
}
export const myEdgeCreationToolModule = new FeatureModule(
(bind, unbind, isBound, rebind) => {
const context = { bind, unbind, isBound, rebind };
bindAsService(context, TYPES.ITool, MyEdgeCreationTool);
configureActionHandler(context, TriggerEdgeCreationAction.KIND, MyEdgeCreationTool);
configureDanglingFeedbackEdge(context);
},
{ featureId: edgeCreationToolModule.featureId }
);
@injectable()
export class MyEdgeCreationTool extends EdgeCreationTool {
protected override creationListener(): void {
const creationListener = new EdgeCreationToolMouseListener(
this.triggerAction,
this.actionDispatcher,
this.typeHintProvider,
this,
20 // drag sensitivity <-- this right here
);
this.toDisposeOnDisable.push(creationListener, this.mouseTool.registerListener(creationListener));
}
} I agree that all those options require more adaptations that might be desirable so in the future we may want to think about adding custom options to each feature so they can be configured more easily. Nevertheless, I hope that helps you solve your issue. |
Beta Was this translation helpful? Give feedback.
Hi Jonathan,
So if you want to get rid of the canvas moving altogether, you need to replace the current mouse listener with one that does nothing on drag using a module, i.e., something like this:
That module needs to be integrated in the container creation of your
GLSPStarter
cla…