do not use event.target for determining clicked gutter region
breakpoints/numbers/foldwidgets
This commit is contained in:
parent
7b365db83f
commit
78471317f6
4 changed files with 27 additions and 9 deletions
|
|
@ -193,7 +193,6 @@ exports.transformTextarea = function(element, loader) {
|
||||||
var settingOpener = document.createElement("div");
|
var settingOpener = document.createElement("div");
|
||||||
applyStyles(settingOpener, {
|
applyStyles(settingOpener, {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
width: "15px",
|
|
||||||
right: "0px",
|
right: "0px",
|
||||||
bottom: "0px",
|
bottom: "0px",
|
||||||
background: "red",
|
background: "red",
|
||||||
|
|
|
||||||
|
|
@ -174,12 +174,32 @@ var Gutter = function(parentEl) {
|
||||||
dom.removeCssClass(this.element, "ace_folding-enabled");
|
dom.removeCssClass(this.element, "ace_folding-enabled");
|
||||||
|
|
||||||
this.$showFoldWidgets = show;
|
this.$showFoldWidgets = show;
|
||||||
|
this.$padding = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getShowFoldWidgets = function() {
|
this.getShowFoldWidgets = function() {
|
||||||
return this.$showFoldWidgets;
|
return this.$showFoldWidgets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.$computePadding = function() {
|
||||||
|
if (!this.element.firstChild)
|
||||||
|
return {left: 0, right: 0};
|
||||||
|
var style = dom.computedStyle(this.element.firstChild);
|
||||||
|
this.$padding = {}
|
||||||
|
this.$padding.left = parseInt(style.paddingLeft) + 1;
|
||||||
|
this.$padding.right = parseInt(style.paddingRight);
|
||||||
|
return this.$padding;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getRegion = function(point) {
|
||||||
|
var padding = this.$padding || this.$computePadding();
|
||||||
|
var rect = this.element.getBoundingClientRect();
|
||||||
|
if (point.x < padding.left + rect.left)
|
||||||
|
return "markers";
|
||||||
|
if (this.$showFoldWidgets && point.x > rect.right - padding.right)
|
||||||
|
return "foldWidgets";
|
||||||
|
};
|
||||||
|
|
||||||
}).call(Gutter.prototype);
|
}).call(Gutter.prototype);
|
||||||
|
|
||||||
exports.Gutter = Gutter;
|
exports.Gutter = Gutter;
|
||||||
|
|
|
||||||
|
|
@ -44,15 +44,11 @@ function GutterHandler(mouseHandler) {
|
||||||
var editor = mouseHandler.editor;
|
var editor = mouseHandler.editor;
|
||||||
|
|
||||||
mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
|
mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
|
||||||
var target = e.domEvent.target || e.domEvent.srcElement;
|
|
||||||
if (target.className.indexOf("ace_gutter-cell") == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!editor.isFocused())
|
if (!editor.isFocused())
|
||||||
return;
|
return;
|
||||||
|
var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
|
||||||
|
|
||||||
var padding = parseInt(dom.computedStyle(target).paddingLeft);
|
if (gutterRegion)
|
||||||
if (e.x < padding + target.getBoundingClientRect().left + 1)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var row = e.getDocumentPosition().row;
|
var row = e.getDocumentPosition().row;
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,12 @@ function FoldHandler(editor) {
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.on("gutterclick", function(e) {
|
editor.on("gutterclick", function(e) {
|
||||||
if (e.domEvent.target.className.indexOf("ace_fold-widget") != -1) {
|
var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
|
||||||
|
|
||||||
|
if (gutterRegion == "foldWidgets") {
|
||||||
var row = e.getDocumentPosition().row;
|
var row = e.getDocumentPosition().row;
|
||||||
editor.session.onFoldWidgetClick(row, e.domEvent);
|
if (editor.session.foldWidgets[row])
|
||||||
|
editor.session.onFoldWidgetClick(row, e);
|
||||||
e.stop();
|
e.stop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue