src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m

Print this page




 873 JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
 874 
 875 - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
 876 {
 877 #ifdef IM_DEBUG
 878     fprintf(stderr, "AWTView InputMethod Selector Called : [insertText]: %s\n", [aString UTF8String]);
 879 #endif // IM_DEBUG
 880 
 881     if (fInputMethodLOCKABLE == NULL) {
 882         return;
 883     }
 884 
 885     // Insert happens at the end of PAH
 886     fInPressAndHold = NO;
 887 
 888     // insertText gets called when the user commits text generated from an input method.  It also gets
 889     // called during ordinary input as well.  We only need to send an input method event when we have marked
 890     // text, or 'text in progress'.  We also need to send the event if we get an insert text out of the blue!
 891     // (i.e., when the user uses the Character palette or Inkwell), or when the string to insert is a complex
 892     // Unicode value.
 893     NSUInteger utf8Length = [aString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
 894 
 895     if ([self hasMarkedText] || !fProcessingKeystroke || (utf8Length > 1)) {
 896         JNIEnv *env = [ThreadUtilities getJNIEnv];
 897 
 898         static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
 899         // We need to select the previous glyph so that it is overwritten.
 900         if (fPAHNeedsToSelect) {
 901             JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
 902             fPAHNeedsToSelect = NO;
 903         }
 904 
 905         static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V");
 906         jstring insertedText =  JNFNSToJavaString(env, aString);
 907         JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
 908         (*env)->DeleteLocalRef(env, insertedText);
 909 
 910         // The input method event will create psuedo-key events for each character in the committed string.
 911         // We also don't want to send the character that triggered the insertText, usually a return. [3337563]
 912         fKeyEventsNeeded = NO;
 913     }
 914 
 915     fPAHNeedsToSelect = NO;




 873 JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
 874 
 875 - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
 876 {
 877 #ifdef IM_DEBUG
 878     fprintf(stderr, "AWTView InputMethod Selector Called : [insertText]: %s\n", [aString UTF8String]);
 879 #endif // IM_DEBUG
 880 
 881     if (fInputMethodLOCKABLE == NULL) {
 882         return;
 883     }
 884 
 885     // Insert happens at the end of PAH
 886     fInPressAndHold = NO;
 887 
 888     // insertText gets called when the user commits text generated from an input method.  It also gets
 889     // called during ordinary input as well.  We only need to send an input method event when we have marked
 890     // text, or 'text in progress'.  We also need to send the event if we get an insert text out of the blue!
 891     // (i.e., when the user uses the Character palette or Inkwell), or when the string to insert is a complex
 892     // Unicode value.
 893     NSUInteger utf16Length = [aString lengthOfBytesUsingEncoding:NSUTF16StringEncoding];
 894 
 895     if ([self hasMarkedText] || !fProcessingKeystroke || (utf16Length > 2)) {
 896         JNIEnv *env = [ThreadUtilities getJNIEnv];
 897 
 898         static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
 899         // We need to select the previous glyph so that it is overwritten.
 900         if (fPAHNeedsToSelect) {
 901             JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
 902             fPAHNeedsToSelect = NO;
 903         }
 904 
 905         static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V");
 906         jstring insertedText =  JNFNSToJavaString(env, aString);
 907         JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
 908         (*env)->DeleteLocalRef(env, insertedText);
 909 
 910         // The input method event will create psuedo-key events for each character in the committed string.
 911         // We also don't want to send the character that triggered the insertText, usually a return. [3337563]
 912         fKeyEventsNeeded = NO;
 913     }
 914 
 915     fPAHNeedsToSelect = NO;