--- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java 2015-04-01 18:37:42.862873300 +0300 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java 2015-04-01 18:37:42.400314500 +0300 @@ -420,7 +420,7 @@ * Tell the component to commit all of the characters in the string to the current * text view. This effectively wipes out any text in progress. */ - synchronized private void insertText(String aString) { + synchronized private void insertText(String aString, int replaceStart, int replaceLength) { AttributedString attribString = new AttributedString(aString); // Set locale information on the new string. @@ -432,7 +432,8 @@ attribString.getIterator(), aString.length(), theCaret, - theCaret); + theCaret, + replaceStart, replaceStart + replaceLength); LWCToolkit.postEvent(LWCToolkit.targetToAppContext(fAwtFocussedComponent), event); fCurrentText = null; fCurrentTextAsString = null; @@ -490,32 +491,6 @@ fCurrentText.addAttribute(TextAttribute.INPUT_METHOD_HIGHLIGHT, theHighlight, begin, end); } - /* Called from JNI to select the previously typed glyph during press and hold */ - private void selectPreviousGlyph() { - if (fIMContext == null) return; // ??? - try { - LWCToolkit.invokeLater(new Runnable() { - public void run() { - final int offset = fIMContext.getInsertPositionOffset(); - if (offset < 1) return; // ??? - - if (fAwtFocussedComponent instanceof JTextComponent) { - ((JTextComponent) fAwtFocussedComponent).select(offset - 1, offset); - return; - } - - if (fAwtFocussedComponent instanceof TextComponent) { - ((TextComponent) fAwtFocussedComponent).select(offset - 1, offset); - return; - } - // TODO: Ideally we want to disable press-and-hold in this case - } - }, fAwtFocussedComponent); - } catch (Exception e) { - e.printStackTrace(); - } - } - private void selectNextGlyph() { if (fIMContext == null || !(fAwtFocussedComponent instanceof JTextComponent)) return; try { @@ -532,7 +507,7 @@ } } - private void dispatchText(int selectStart, int selectLength, boolean pressAndHold) { + private void dispatchText(int selectStart, int selectLength, int replaceStart, int replaceEnd, boolean pressAndHold) { // Nothing to do if we have no text. if (fCurrentText == null) return; @@ -545,7 +520,8 @@ fCurrentText.getIterator(), 0, theCaret, - visiblePosition); + visiblePosition, + replaceStart, replaceStart + replaceEnd); LWCToolkit.postEvent(LWCToolkit.targetToAppContext(fAwtFocussedComponent), event); if (pressAndHold) selectNextGlyph();