Skip to content

add option to disable right mouse button events (specifically RMB drag) #6030

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

Open
secretwpn opened this issue Nov 19, 2021 · 1 comment
Open
Labels
feature something new P3 backlog

Comments

@secretwpn
Copy link

There is an existing bug report (that for some reason did not get any traction): #5311

If fixing this issue specifically is far out of current roadmap or too complex - maybe it would be possible to add an option to disable right mouse button interactions altogether?

I've spent some hours trying to ignore various events (mouseup, oncontextmenu) for my plot and its parent components
but was not able to stop Plotly from interacting with right mouse button drag.

@Freddicola
Copy link

I tried to avoid this issue like below:
I hope that your issue would be resolved: :^)

  setupRMouseDragBlocker() {
    this.owner.layout.xaxis.last_range = this.owner.layout.xaxis.range;
    this.owner.on(
      "plotly_relayout",
      function (data) {
        if ("xaxis.autorange" in data || "plot_mounted" in data) {
          console.log("data", data, "owner", this.owner.layout);
          if (this.owner.layout.xaxis.range) {
            this.owner.layout.xaxis.last_range = copy(this.owner.layout.xaxis.range);
          }
          return;
        }

        if ("xaxis.range[0]" in data) {
          const begin = data["xaxis.range[0]"];
          const end = data["xaxis.range[1]"];

          if (begin == end) {
            console.log(`prevent: begin:${begin}, end: ${end}`);
            // prevent re
            console.log(
              "plotly_relayout",
              data,
              "get last_range:",
              this.owner.layout.xaxis.last_range
            );
            const new_layout = this.graph.getLayout();
            new_layout.xaxis.range = this.owner.layout.xaxis.last_range;
            new_layout.xaxis.last_range = this.owner.layout.xaxis.last_range;
            Plotly.relayout(this.owner, new_layout);
          } else {
            this.owner.layout.xaxis.last_range = [begin, end];
          }
        }
      }.bind(this)
    );
    Plotly.relayout(this.owner, { plot_mounted: true });
  }

@gvwilson gvwilson self-assigned this Jul 3, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson changed the title Option to disable right mouse button events (specifically RMB drag) add option to disable right mouse button events (specifically RMB drag) Aug 9, 2024
@gvwilson gvwilson added feature something new P3 backlog labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests

3 participants