diff options
-rw-r--r-- | src/macosx/native/sun/awt/AWTView.m | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/macosx/native/sun/awt/AWTView.m b/src/macosx/native/sun/awt/AWTView.m index 919f9692a5..696a686a58 100644 --- a/src/macosx/native/sun/awt/AWTView.m +++ b/src/macosx/native/sun/awt/AWTView.m @@ -57,6 +57,13 @@ //#define IM_DEBUG TRUE //#define EXTRA_DEBUG +static BOOL shouldUsePressAndHold() { + static int shouldUsePressAndHold = -1; + if (shouldUsePressAndHold != -1) return shouldUsePressAndHold; + shouldUsePressAndHold = !isSnowLeopardOrLower(); + return shouldUsePressAndHold; +} + @implementation AWTView @synthesize _dropTarget; @@ -79,6 +86,10 @@ AWT_ASSERT_APPKIT_THREAD; fKeyEventsNeeded = NO; fProcessingKeystroke = NO; + fEnablePressAndHold = shouldUsePressAndHold(); + fInPressAndHold = NO; + fPAHNeedsToSelect = NO; + mouseIsOver = NO; [self resetTrackingArea]; [self setAutoresizesSubviews:NO]; @@ -280,6 +291,15 @@ AWT_ASSERT_APPKIT_THREAD; // Allow TSM to look at the event and potentially send back NSTextInputClient messages. [self interpretKeyEvents:[NSArray arrayWithObject:event]]; + if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod]) { + fProcessingKeystroke = NO; + if (!fInPressAndHold) { + fInPressAndHold = YES; + fPAHNeedsToSelect = YES; + } + return; + } + NSString *eventCharacters = [event characters]; BOOL isDeadKey = (eventCharacters != nil && [eventCharacters length] == 0); @@ -357,7 +377,10 @@ AWT_ASSERT_APPKIT_THREAD; AWTToolkit.latestPerformKeyEquivalentEvent = event; [event retain]; - [self deliverJavaKeyEventHelper: event]; + // if IM is active key events should be ignored + if (![self hasMarkedText] && !fInPressAndHold) { + [self deliverJavaKeyEventHelper: event]; + } return NO; } @@ -1115,6 +1138,9 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod"); return; } + // Insert happens at the end of PAH + fInPressAndHold = NO; + // insertText gets called when the user commits text generated from an input method. It also gets // called during ordinary input as well. We only need to send an input method event when we have marked // text, or 'text in progress'. We also need to send the event if we get an insert text out of the blue! |