Skip to content

Turn off canvas dragging with left click and mouse movement #1385

Answered by martin-fleck-at
jmenzies12 asked this question in Q&A
Discussion options

You must be logged in to vote

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 GLSPStarter cla…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jmenzies12
Comment options

Answer selected by jmenzies12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants