| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 { | 91 { |
| 92 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 92 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 93 | 93 |
| 94 [mInputTextView release]; | 94 [mInputTextView release]; |
| 95 | 95 |
| 96 [super dealloc]; | 96 [super dealloc]; |
| 97 } | 97 } |
| 98 | 98 |
| 99 - (void)keyboardInputSourceChanged:(NSNotification *)notification | 99 - (void)keyboardInputSourceChanged:(NSNotification *)notification |
| 100 { | 100 { |
| 101 [mInputTextView setString:@""]; | 101 [self cancelComposition]; |
| 102 [self orderOut:nil]; | |
| 103 } | 102 } |
| 104 | 103 |
| 105 - (BOOL)interpretKeyEvent:(NSEvent*)event string:(NSString**)string | 104 - (BOOL)interpretKeyEvent:(NSEvent*)event string:(NSString**)string |
| 106 { | 105 { |
| 107 BOOL hadMarkedText = [mInputTextView hasMarkedText]; | 106 BOOL hadMarkedText = [mInputTextView hasMarkedText]; |
| 108 | 107 |
| 109 *string = nil; | 108 *string = nil; |
| 110 | 109 |
| 111 if (![[mInputTextView inputContext] handleEvent:event]) | 110 if (![[mInputTextView inputContext] handleEvent:event]) |
| 112 return NO; | 111 return NO; |
| 113 | 112 |
| 114 if ([mInputTextView hasMarkedText]) { | 113 if ([mInputTextView hasMarkedText]) { |
| 115 // Don't show the input method window for dead keys | 114 // Don't show the input method window for dead keys |
| 116 if ([[event characters] length] > 0) | 115 if ([[event characters] length] > 0) |
| 117 [self orderFront:nil]; | 116 [self orderFront:nil]; |
| 118 | 117 |
| 119 return YES; | 118 return YES; |
| 120 } else { | 119 } else { |
| 121 [self orderOut:nil]; | 120 [self orderOut:nil]; |
| 122 | 121 |
| 123 NSString *text = [[mInputTextView textStorage] string]; | 122 NSString *text = [[mInputTextView textStorage] string]; |
| 124 if ([text length] > 0) | 123 if ([text length] > 0) |
| 125 *string = [[text copy] autorelease]; | 124 *string = [[text copy] autorelease]; |
| 126 } | 125 } |
| 127 | 126 |
| 128 [mInputTextView setString:@""]; | 127 [mInputTextView setString:@""]; |
| 129 return hadMarkedText; | 128 return hadMarkedText; |
| 130 } | 129 } |
| 131 | 130 |
| 132 - (void)cancelInput | |
| 133 { | |
| 134 [self orderOut:nil]; | |
| 135 [mInputTextView setString:@""]; | |
| 136 } | |
| 137 | |
| 138 - (NSTextInputContext*)inputContext | 131 - (NSTextInputContext*)inputContext |
| 139 { | 132 { |
| 140 return [mInputTextView inputContext]; | 133 return [mInputTextView inputContext]; |
| 141 } | 134 } |
| 142 | 135 |
| 136 - (void)cancelComposition |
| 137 { |
| 138 [mInputTextView setString:@""]; |
| 139 [self orderOut:nil]; |
| 140 } |
| 141 |
| 142 - (BOOL)inComposition |
| 143 { |
| 144 return [mInputTextView hasMarkedText]; |
| 145 } |
| 146 |
| 143 @end | 147 @end |
| OLD | NEW |