Added option for annotation tooltip to be floating (follows mouse, current functionality) or fixed (stationary per annotation).
This commit is contained in:
parent
d226ea067b
commit
e9434fc1df
3 changed files with 26 additions and 3 deletions
|
|
@ -1029,6 +1029,18 @@ var Editor = function(renderer, session) {
|
||||||
this.getHighlightGutterLine = function() {
|
this.getHighlightGutterLine = function() {
|
||||||
return this.getOption("highlightGutterLine");
|
return this.getOption("highlightGutterLine");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if the annotation tooltip follows the mouse or is stationary to the annotation.
|
||||||
|
* @return {Boolean}
|
||||||
|
**/
|
||||||
|
this.setTooltipFollowsMouse = function(tooltipShouldFollowMouse) {
|
||||||
|
this.setOption("tooltipFollowsMouse", tooltipShouldFollowMouse);
|
||||||
|
};
|
||||||
|
this.getTooltipFollowsMouse = function() {
|
||||||
|
return this.getOption("tooltipFollowsMouse");
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the currently selected word should be highlighted.
|
* Determines if the currently selected word should be highlighted.
|
||||||
* @param {Boolean} shouldHighlight Set to `true` to highlight the currently selected word
|
* @param {Boolean} shouldHighlight Set to `true` to highlight the currently selected word
|
||||||
|
|
@ -2432,6 +2444,7 @@ config.defineOptions(Editor.prototype, "editor", {
|
||||||
dragDelay: "$mouseHandler",
|
dragDelay: "$mouseHandler",
|
||||||
dragEnabled: "$mouseHandler",
|
dragEnabled: "$mouseHandler",
|
||||||
focusTimout: "$mouseHandler",
|
focusTimout: "$mouseHandler",
|
||||||
|
tooltipFollowsMouse: "$mouseHandler",
|
||||||
|
|
||||||
firstLineNumber: "session",
|
firstLineNumber: "session",
|
||||||
overwrite: "session",
|
overwrite: "session",
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,16 @@ function GutterHandler(mouseHandler) {
|
||||||
tooltip.innerHTML = tooltipAnnotation;
|
tooltip.innerHTML = tooltipAnnotation;
|
||||||
editor.on("mousewheel", hideTooltip);
|
editor.on("mousewheel", hideTooltip);
|
||||||
|
|
||||||
moveTooltip(mouseEvent);
|
if (mouseHandler.$tooltipFollowsMouse) {
|
||||||
|
moveTooltip(mouseEvent);
|
||||||
|
} else {
|
||||||
|
gutterElement = gutter.$cells[row].element;
|
||||||
|
var rect = gutterElement.getBoundingClientRect();
|
||||||
|
var tooltipLeft = rect.right;
|
||||||
|
var tooltipTop = rect.top + Math.round(rect.height / 2);
|
||||||
|
tooltip.style.left = tooltipLeft + "px";
|
||||||
|
tooltip.style.top = tooltipTop - 5 + "px";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideTooltip() {
|
function hideTooltip() {
|
||||||
|
|
@ -127,7 +136,7 @@ function GutterHandler(mouseHandler) {
|
||||||
if (dom.hasCssClass(target, "ace_fold-widget"))
|
if (dom.hasCssClass(target, "ace_fold-widget"))
|
||||||
return hideTooltip();
|
return hideTooltip();
|
||||||
|
|
||||||
if (tooltipAnnotation)
|
if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
|
||||||
moveTooltip(e);
|
moveTooltip(e);
|
||||||
|
|
||||||
mouseEvent = e;
|
mouseEvent = e;
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,8 @@ config.defineOptions(MouseHandler.prototype, "mouseHandler", {
|
||||||
scrollSpeed: {initialValue: 2},
|
scrollSpeed: {initialValue: 2},
|
||||||
dragDelay: {initialValue: 150},
|
dragDelay: {initialValue: 150},
|
||||||
dragEnabled: {initialValue: true},
|
dragEnabled: {initialValue: true},
|
||||||
focusTimout: {initialValue: 0}
|
focusTimout: {initialValue: 0},
|
||||||
|
tooltipFollowsMouse: {initialValue: true}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue