From f5a89c3de8635d6564d462ab21682c38296bef79 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 16 Jun 2020 10:26:27 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-33690=20=E6=8A=BD=E5=87=BA=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/javascript/JSContentPane.java | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java b/designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java index da0910126..2ca2d6e66 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java @@ -87,22 +87,14 @@ public class JSContentPane extends BasicPane { contentTextArea.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { - if (ac == null) { - CompletionProvider provider = createCompletionProvider(); - ac = new AutoCompletion(provider); - String shortCuts = DesignerEnvManager.getEnvManager().getAutoCompleteShortcuts(); - - ac.setTriggerKey(convert2KeyStroke(shortCuts)); - ac.install(contentTextArea); - } + // 获得焦点时 安装 + installAutoCompletion(); } @Override public void focusLost(FocusEvent e) { - if (ac != null) { - ac.uninstall(); - ac = null; - } + // 失去焦点时 卸载 + uninstallAutoCompletion(); } }); @@ -115,6 +107,30 @@ public class JSContentPane extends BasicPane { return KeyStroke.getKeyStroke(ks.replace("+", "pressed")); } + /** + * 注册安装 自动补全监听 + */ + private void installAutoCompletion() { + if (ac == null) { + CompletionProvider provider = createCompletionProvider(); + ac = new AutoCompletion(provider); + String shortCuts = DesignerEnvManager.getEnvManager().getAutoCompleteShortcuts(); + + ac.setTriggerKey(convert2KeyStroke(shortCuts)); + ac.install(contentTextArea); + } + } + + /** + * 卸载移除 自动补全监听 + */ + private void uninstallAutoCompletion() { + if (ac != null) { + ac.uninstall(); + ac = null; + } + } + @Override protected String title4PopupWindow() { return "JS";