diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index fd4a15a3d6f..b4c5f453d8d 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -647,6 +647,15 @@ public class LWCToolkit extends LWToolkit { return InputEvent.CTRL_MASK | InputEvent.ALT_MASK; } + /** + * Tests whether specified key modifiers mask can be used to enter a printable + * character. + */ + @Override + public boolean isPrintableCharacterModifiersMask(int mods) { + return ((mods & (InputEvent.META_MASK | InputEvent.CTRL_MASK)) == 0); + } + // Extends PeerEvent because we want to pass long an ObjC mediator object and because we want these events to be posted early // Typically, rather than relying on the notifier to call notifyAll(), we use the mediator to stop the runloop public static class CPeerEvent extends PeerEvent { diff --git a/jdk/src/share/classes/javax/swing/text/DefaultEditorKit.java b/jdk/src/share/classes/javax/swing/text/DefaultEditorKit.java index ba90af7dcf2..775e7393cb6 100644 --- a/jdk/src/share/classes/javax/swing/text/DefaultEditorKit.java +++ b/jdk/src/share/classes/javax/swing/text/DefaultEditorKit.java @@ -24,6 +24,8 @@ */ package javax.swing.text; +import sun.awt.SunToolkit; + import java.io.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -869,11 +871,18 @@ public class DefaultEditorKit extends EditorKit { } String content = e.getActionCommand(); int mod = e.getModifiers(); - if ((content != null) && (content.length() > 0) && - ((mod & ActionEvent.ALT_MASK) == (mod & ActionEvent.CTRL_MASK))) { - char c = content.charAt(0); - if ((c >= 0x20) && (c != 0x7F)) { - target.replaceSelection(content); + if ((content != null) && (content.length() > 0)) { + boolean isPrintableMask = true; + Toolkit tk = Toolkit.getDefaultToolkit(); + if (tk instanceof SunToolkit) { + isPrintableMask = ((SunToolkit)tk).isPrintableCharacterModifiersMask(mod); + } + + if (isPrintableMask) { + char c = content.charAt(0); + if ((c >= 0x20) && (c != 0x7F)) { + target.replaceSelection(content); + } } } } diff --git a/jdk/src/share/classes/sun/awt/SunToolkit.java b/jdk/src/share/classes/sun/awt/SunToolkit.java index 132c1d6c6d7..19cfdf41711 100644 --- a/jdk/src/share/classes/sun/awt/SunToolkit.java +++ b/jdk/src/share/classes/sun/awt/SunToolkit.java @@ -1125,6 +1125,16 @@ public abstract class SunToolkit extends Toolkit return InputEvent.ALT_MASK; } + /** + * Tests whether specified key modifiers mask can be used to enter a printable + * character. This is a default implementation of this method, which reflects + * the way things work on Windows: here, pressing ctrl + alt allows user to enter + * characters from the extended character set (like euro sign or math symbols) + */ + public boolean isPrintableCharacterModifiersMask(int mods) { + return ((mods & InputEvent.ALT_MASK) == (mods & InputEvent.CTRL_MASK)); + } + /** * Returns a new input method window, with behavior as specified in * {@link java.awt.im.spi.InputMethodContext#createInputMethodWindow}.