当我使用鼠标时,我想在ace编辑器中划出一部分代码,更重要的是,将鼠标光标显示为指针。我试过这样做:
editSession.addMarker(new Range(loc.start.line - 1, loc.start.column, loc.end.line - 1, loc.end.column), "ace_underline", "text")这不管用。但令我困惑的是,如果我用ace_underline或ace_selection替换ace_highlight-marker ( addMarker函数的第二个参数),它的工作原理是我想要的范围被着色。
我还尝试创建自己的css类,如下所示:
.myCustomMouseOverHighlight {
text-decoration: underline;
cursor: pointer !important;
}然后将第二个参数替换为myCustomMouseOverHighlight,但同样没有效果。
任何指示都将受到高度赞赏。
拉杜
发布于 2013-12-05 08:53:05
它不能工作,因为addMarker在文本后面添加了一个div。试一试
.myCustomMouseOverHighlight {
border-bottom: 1px solid red;
position: absolute;
cursor: pointer !important;
pointer-events: auto;
}
<script src="https://ajaxorg.github.io/ace-builds/src/ace.js"></script>
<style>
.myCustomMouseOverHighlight {
border-bottom: 1px solid red;
position: absolute;
cursor: pointer !important;
pointer-events: auto;
}
</style>
<script>
var Range = ace.Range;
var editor = ace.edit(null, {value: "Hello World"});
editor.container.style.height = "100px";
document.body.appendChild(editor.container);
editor.session.addMarker(new Range(0, 1, 0, 5), "myCustomMouseOverHighlight", "text")
</script>
https://stackoverflow.com/questions/20376008
复制相似问题