检测右键单击Ace编辑器 [英] Detect a right-click on Ace editor

查看:130
本文介绍了检测右键单击Ace编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Ace编辑器上检测右键单击事件?

Is there a way to detect a right-click event on Ace editor?

我正在尝试添加这样的监听器:

I've being trying to add a listener like this:

  editor.session.addEventListener('contextmenu', function(e) {
      e.preventDefault();
      alert('success!');
      return false;
  }, false);

这个

  editor.addEventListener('contextmenu', function(e) {
      e.preventDefault();
      alert('success!');
      return false;
  }, false);

但没有成功。

谢谢!

推荐答案

在包含编辑器的元素上添加事件监听器

add event listener on the element containing the editor

editor.container.addEventListener("contextmenu", function(e) {
    e.preventDefault();
    alert('success!');
    return false;
}, false);

这篇关于检测右键单击Ace编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆