src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m
Print this page
*** 82,92 ****
fKeyEventsNeeded = NO;
fProcessingKeystroke = NO;
fEnablePressAndHold = shouldUsePressAndHold();
fInPressAndHold = NO;
- fPAHNeedsToSelect = NO;
mouseIsOver = NO;
[self resetTrackingArea];
[self setAutoresizesSubviews:NO];
--- 82,91 ----
*** 285,295 ****
if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod]) {
fProcessingKeystroke = NO;
if (!fInPressAndHold) {
fInPressAndHold = YES;
- fPAHNeedsToSelect = YES;
}
return;
}
NSString *eventCharacters = [event characters];
--- 284,293 ----
*** 876,886 ****
JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
{
#ifdef IM_DEBUG
! fprintf(stderr, "AWTView InputMethod Selector Called : [insertText]: %s\n", [aString UTF8String]);
#endif // IM_DEBUG
if (fInputMethodLOCKABLE == NULL) {
return;
}
--- 874,884 ----
JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
{
#ifdef IM_DEBUG
! fprintf(stderr, "AWTView InputMethod Selector Called : [insertText]: %s Repl: loc=%lu, length=%lu \n", [aString UTF8String], (unsigned long)replacementRange.location, (unsigned long)replacementRange.length);
#endif // IM_DEBUG
if (fInputMethodLOCKABLE == NULL) {
return;
}
*** 896,924 ****
NSUInteger utf16Length = [aString lengthOfBytesUsingEncoding:NSUTF16StringEncoding];
if ([self hasMarkedText] || !fProcessingKeystroke || (utf16Length > 2)) {
JNIEnv *env = [ThreadUtilities getJNIEnv];
! static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
! // We need to select the previous glyph so that it is overwritten.
! if (fPAHNeedsToSelect) {
! JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
! fPAHNeedsToSelect = NO;
! }
!
! static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V");
jstring insertedText = JNFNSToJavaString(env, aString);
! JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
(*env)->DeleteLocalRef(env, insertedText);
// The input method event will create psuedo-key events for each character in the committed string.
// We also don't want to send the character that triggered the insertText, usually a return. [3337563]
fKeyEventsNeeded = NO;
}
-
- fPAHNeedsToSelect = NO;
-
}
- (void) doCommandBySelector:(SEL)aSelector
{
#ifdef IM_DEBUG
--- 894,914 ----
NSUInteger utf16Length = [aString lengthOfBytesUsingEncoding:NSUTF16StringEncoding];
if ([self hasMarkedText] || !fProcessingKeystroke || (utf16Length > 2)) {
JNIEnv *env = [ThreadUtilities getJNIEnv];
! static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;II)V");
jstring insertedText = JNFNSToJavaString(env, aString);
! JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText,
! replacementRange.location == NSNotFound ? -1 : replacementRange.location,
! replacementRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
(*env)->DeleteLocalRef(env, insertedText);
// The input method event will create psuedo-key events for each character in the committed string.
// We also don't want to send the character that triggered the insertText, usually a return. [3337563]
fKeyEventsNeeded = NO;
}
}
- (void) doCommandBySelector:(SEL)aSelector
{
#ifdef IM_DEBUG
*** 939,953 ****
BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]];
NSAttributedString *attrString = (isAttributedString ? (NSAttributedString *)aString : nil);
NSString *incomingString = (isAttributedString ? [aString string] : aString);
#ifdef IM_DEBUG
! fprintf(stderr, "AWTView InputMethod Selector Called : [setMarkedText] \"%s\", loc=%lu, length=%lu\n", [incomingString UTF8String], (unsigned long)selectionRange.location, (unsigned long)selectionRange.length);
#endif // IM_DEBUG
static JNF_MEMBER_CACHE(jm_startIMUpdate, jc_CInputMethod, "startIMUpdate", "(Ljava/lang/String;)V");
static JNF_MEMBER_CACHE(jm_addAttribute, jc_CInputMethod, "addAttribute", "(ZZII)V");
! static JNF_MEMBER_CACHE(jm_dispatchText, jc_CInputMethod, "dispatchText", "(IIZ)V");
JNIEnv *env = [ThreadUtilities getJNIEnv];
// NSInputContext already did the analysis of the TSM event and created attributes indicating
// the underlining and color that should be done to the string. We need to look at the underline
// style and color to determine what kind of Java hilighting needs to be done.
--- 929,945 ----
BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]];
NSAttributedString *attrString = (isAttributedString ? (NSAttributedString *)aString : nil);
NSString *incomingString = (isAttributedString ? [aString string] : aString);
#ifdef IM_DEBUG
! fprintf(stderr, "AWTView InputMethod Selector Called : [setMarkedText] \"%s\", Sel: loc=%lu, length=%lu, Repl: loc=%lu, length=%lu\n",
! [incomingString UTF8String], (unsigned long)selectionRange.location, (unsigned long)selectionRange.length,
! (unsigned long)replacementRange.location, (unsigned long)replacementRange.length);
#endif // IM_DEBUG
static JNF_MEMBER_CACHE(jm_startIMUpdate, jc_CInputMethod, "startIMUpdate", "(Ljava/lang/String;)V");
static JNF_MEMBER_CACHE(jm_addAttribute, jc_CInputMethod, "addAttribute", "(ZZII)V");
! static JNF_MEMBER_CACHE(jm_dispatchText, jc_CInputMethod, "dispatchText", "(IIIIZ)V");
JNIEnv *env = [ThreadUtilities getJNIEnv];
// NSInputContext already did the analysis of the TSM event and created attributes indicating
// the underlining and color that should be done to the string. We need to look at the underline
// style and color to determine what kind of Java hilighting needs to be done.
*** 978,995 ****
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_addAttribute, isThickUnderline, isGray, effectiveRange.location, effectiveRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
}
}
}
! static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
! // We need to select the previous glyph so that it is overwritten.
! if (fPAHNeedsToSelect) {
! JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
! fPAHNeedsToSelect = NO;
! }
!
! JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText, selectionRange.location, selectionRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode)
// If the marked text is being cleared (zero-length string) don't handle the key event.
if ([incomingString length] == 0) {
fKeyEventsNeeded = NO;
}
--- 970,982 ----
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_addAttribute, isThickUnderline, isGray, effectiveRange.location, effectiveRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
}
}
}
! JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText, selectionRange.location, selectionRange.length,
! replacementRange.location == NSNotFound ? -1 : replacementRange.location,
! replacementRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode)
// If the marked text is being cleared (zero-length string) don't handle the key event.
if ([incomingString length] == 0) {
fKeyEventsNeeded = NO;
}