From 38a5a522c2d17cd909346186813e2385c4c437bc Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 6 Dec 2012 02:35:43 +0400 Subject: [PATCH] allow displaying spellcheck suggestions in contextmenu --- lib/ace/keyboard/textinput.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 77412920..be5202d3 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -359,12 +359,17 @@ var TextInput = function(parentNode, host) { if (!tempStyle) tempStyle = text.style.cssText; - text.style.cssText = - "position:fixed; z-index:100000;" + - (useragent.isIE ? "background:rgba(0, 0, 0, 0.03); opacity:0.1;" : "") + //"background:rgba(250, 0, 0, 0.3); opacity:1;" + - "left:" + (e.clientX - 2) + "px; top:" + (e.clientY - 2) + "px;"; + text.style.cssText = "z-index:100000;" + + (useragent.isIE ? "opacity:0.1;" : "")// + "background:rgba(250, 0, 0, 0.3); opacity:1;" resetSelection(host.selection.isEmpty()); + host._emit("nativecontextmenu", {target: editor}); + var rect = host.container.getBoundingClientRect(); + var move = function(e) { + text.style.left = e.clientX - rect.left - 2 + "px"; + text.style.top = e.clientY - rect.top - 2 + "px"; + }; + move(e); if (e.type != "mousedown") return; @@ -374,10 +379,7 @@ var TextInput = function(parentNode, host) { // on windows context menu is opened after mouseup if (useragent.isWin) - event.capture(host.container, function(e) { - text.style.left = e.clientX - 2 + "px"; - text.style.top = e.clientY - 2 + "px"; - }, onContextMenuClose); + event.capture(host.container, move, onContextMenuClose); }; function onContextMenuClose() {