From ec1250184f55fb51690cdb30976929f168be6a64 Mon Sep 17 00:00:00 2001 From: weisj Date: Sun, 3 May 2020 12:13:34 +0200 Subject: [PATCH] Removed parent actions from EditorPane. --- .../weisj/darklaf/ui/text/DarkEditorPaneUI.java | 11 ++++++++++- .../com/github/weisj/darklaf/ui/text/DarkTextUI.java | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkEditorPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkEditorPaneUI.java index 3a9b7587..86d345fe 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkEditorPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkEditorPaneUI.java @@ -28,12 +28,16 @@ import java.awt.*; import java.beans.PropertyChangeEvent; import javax.swing.*; +import javax.swing.plaf.ActionMapUIResource; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.text.*; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.StyleSheet; +import com.github.weisj.darklaf.ui.text.action.DeleteNextCharAction; +import com.github.weisj.darklaf.ui.text.action.DeletePreviousCharAction; +import com.github.weisj.darklaf.ui.text.action.ToggleInsertAction; import com.github.weisj.darklaf.util.PropertyKey; import com.github.weisj.darklaf.util.PropertyUtil; @@ -242,7 +246,7 @@ public class DarkEditorPaneUI extends DarkTextUI { * Fetch an action map to use. The map for a JEditorPane is not shared because it changes with the EditorKit. */ public ActionMap getActionMap() { - ActionMap am = super.getActionMap(); + ActionMap am = new ActionMapUIResource(); am.put("requestFocus", new FocusAction()); EditorKit editorKit = getEditorKit(getComponent()); if (editorKit != null) { @@ -257,6 +261,11 @@ public class DarkEditorPaneUI extends DarkTextUI { TransferHandler.getCopyAction()); am.put(TransferHandler.getPasteAction().getValue(Action.NAME), TransferHandler.getPasteAction()); + if (editorKit instanceof DefaultEditorKit) { + am.put(DefaultEditorKit.deletePrevCharAction, new DeletePreviousCharAction()); + am.put(DefaultEditorKit.deleteNextCharAction, new DeleteNextCharAction()); + am.put(TOGGLE_INSERT, new ToggleInsertAction()); + } return am; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java index 4f43ecaf..393c72e1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java @@ -376,7 +376,6 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi * processed when the text component has focus and isn't editable. * */ - System.out.println(getEditorKit(editor)); if (getEditorKit(editor) instanceof DefaultEditorKit) { if (map != null) { Object obj = map.get(DefaultEditorKit.insertBreakAction);