Ticket #22948: 22948.patch
File 22948.patch, 2.8 KB (added by , 18 months ago) |
---|
-
src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java
Subject: [PATCH] Fix #22948: Add system shortcuts for undo/redo to text boxes --- IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 diff --git a/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java b/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java
a b 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.KeyEvent; 9 9 import java.beans.PropertyChangeListener; 10 import java.util.Optional; 10 11 11 12 import javax.swing.AbstractAction; 12 13 import javax.swing.Action; … … 25 26 import org.openstreetmap.josm.tools.ImageProvider; 26 27 import org.openstreetmap.josm.tools.Logging; 27 28 import org.openstreetmap.josm.tools.PlatformManager; 29 import org.openstreetmap.josm.tools.Shortcut; 28 30 29 31 /** 30 32 * A popup menu designed for text components. It displays the following actions: … … 97 99 if (!undoRedo) { 98 100 component.getDocument().addUndoableEditListener(undoEditListener); 99 101 if (!GraphicsEnvironment.isHeadless()) { 100 component.getInputMap().put( 101 KeyStroke.getKeyStroke(KeyEvent.VK_Z, PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()), undoAction); 102 component.getInputMap().put( 103 KeyStroke.getKeyStroke(KeyEvent.VK_Y, PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()), redoAction); 102 final Optional<Shortcut> undoShortcut = Shortcut.listAll().stream() 103 .filter(shortcut -> "system:undo".equals(shortcut.getShortText())).findFirst(); 104 final Optional<Shortcut> redoShortcut = Shortcut.listAll().stream() 105 .filter(shortcut -> "system:redo".equals(shortcut.getShortText())).findFirst(); 106 if (undoShortcut.isPresent()) { 107 component.getInputMap().put(undoShortcut.get().getKeyStroke(), undoAction); 108 } else { 109 component.getInputMap().put( 110 KeyStroke.getKeyStroke(KeyEvent.VK_Z, PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()), undoAction); 111 } 112 if (redoShortcut.isPresent()) { 113 component.getInputMap().put(redoShortcut.get().getKeyStroke(), redoAction); 114 } else { 115 component.getInputMap().put( 116 KeyStroke.getKeyStroke(KeyEvent.VK_Y, PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()), redoAction); 117 } 104 118 } 105 119 undoRedo = true; 106 120 }