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

Distinct between left- and right-mouse-button click in SectionTool.js #75

Open
indianscout opened this issue Jun 24, 2021 · 0 comments
Open
Milestone

Comments

@indianscout
Copy link

The SectionTool binds "mouseclicked" event and recieves the x/y coords to display the section-control-utility.
When left-mouse-button is clicked:
image

Unfortunately it also displays the section-control-utility AND the context menu when right-mouse-button is clicked:
image

From a UX perspective this behaviour is not ideal. Either the section-control-utility OR the context menu should appear.
To achieve this it is necessary to distinct between these two different clicks like:

switch (event.which) {
        case 1:
            alert('Left Mouse button pressed.');
            break;
        case 2:
            alert('Middle Mouse button pressed.');
            break;
        case 3:
            alert('Right Mouse button pressed.');
            break;
        default:
            alert('You have a strange Mouse!');
    }

Unfortunately the "mouseclicked" event does not deliver the originating event to distinguish these cases (https://github.com/xeokit/xeokit-bim-viewer/blob/master/src/toolbar/SectionTool.js#L143).

_initSectionMode() {

        this.viewer.scene.input.on("mouseclicked", (coords) => {
            if (!this.getActive() || !this.getEnabled()) {
                return;
            }
            
            const pickResult = this.viewer.scene.pick({
                canvasPos: coords,
                pickSurface: true  // <<------ This causes picking to find the intersection point on the entity
            });

            if (pickResult) {

                const sectionPlane = this._sectionPlanesPlugin.createSectionPlane({
                    pos: pickResult.worldPos,
                    dir: math.mulVec3Scalar(pickResult.worldNormal, -1)
                });

                sectionPlane.on("destroyed", () => {
                    this._updateSectionPlanesCount();
                });

                this._sectionPlanesPlugin.showControl(sectionPlane.id);

                this._updateSectionPlanesCount();
            }
        });

Is there a way to distinct between left and right-mouse-button click in _initSectionMode()?

I suspect this probably needs to be changed in https://github.com/xeokit/xeokit-sdk...
Any suggestions are welcome.

@xeolabs xeolabs added this to the 2.3.13 milestone Nov 10, 2021
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

2 participants