Code Monkey home page Code Monkey logo

Comments (5)

XiChaoMing avatar XiChaoMing commented on August 16, 2024

不管 Windows 还是 Mac,好像都没法阻止默认的右键弹窗~

[
    S2Event.GLOBAL_SCROLL,
    S2Event.ROW_CELL_CLICK,
    S2Event.COL_CELL_CLICK,
    S2Event.CORNER_CELL_CLICK,
    S2Event.DATA_CELL_CLICK,
    S2Event.GLOBAL_SELECTED,
    S2Event.DATA_CELL_BRUSH_SELECTION,
    S2Event.LAYOUT_RESIZE,
    S2Event.GLOBAL_CONTEXT_MENU,
].forEach((eventName) => {
  s2.on(eventName, event => {
    if (eventName === S2Event.GLOBAL_CONTEXT_MENU) {
      // 没有效果
      event.preventDefault();
      event.stopPropagation();

      // 这样也没有效果
      event.originalEvent.preventDefault();
      event.originalEvent.stopPropagation();
    }
  });
});

from s2.

lijinke666 avatar lijinke666 commented on August 16, 2024

不管 Windows 还是 Mac,好像都没法阻止默认的右键弹窗~

[
    S2Event.GLOBAL_SCROLL,
    S2Event.ROW_CELL_CLICK,
    S2Event.COL_CELL_CLICK,
    S2Event.CORNER_CELL_CLICK,
    S2Event.DATA_CELL_CLICK,
    S2Event.GLOBAL_SELECTED,
    S2Event.DATA_CELL_BRUSH_SELECTION,
    S2Event.LAYOUT_RESIZE,
    S2Event.GLOBAL_CONTEXT_MENU,
].forEach((eventName) => {
  s2.on(eventName, event => {
    if (eventName === S2Event.GLOBAL_CONTEXT_MENU) {
      // 没有效果
      event.preventDefault();
      event.stopPropagation();

      // 这样也没有效果
      event.originalEvent.preventDefault();
      event.originalEvent.stopPropagation();
    }
  });
});

2.0 版本右键事件使用的 G 的 rightdown/rightup, 默认事件并不是右键菜单 (具体可以参考G 文档), 所以 preventDefault 无效, 需要这样写, 需要监听 <canvas/> DOM 元素, 后面补充下文档

s2.getCanvasElement().addEventListener('contextmenu', (event) => {
    event.preventDefault();
 });

from s2.

github-actions avatar github-actions commented on August 16, 2024

你好 @XiChaoMing,很抱歉给你带来了不好的体验, 我们会尽快排查问题并修复, 请关注后续发布日志.

Hello, @XiChaoMing, We are so sorry for the bad experience. We will troubleshoot and fix the problem as soon as possible. Please pay attention to the follow-up change logs.

from s2.

lijinke666 avatar lijinke666 commented on August 16, 2024

🎉 This issue has been resolved in version @antv/s2-v2.0.0-next.19 🎉

The release is available on:

Your semantic-release bot 📦🚀

from s2.

lijinke666 avatar lijinke666 commented on August 16, 2024

🎉 This issue has been resolved in version @antv/s2-react-v2.0.0-next.18 🎉

The release is available on:

Your semantic-release bot 📦🚀

from s2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.