Fixes an exception.

This commit is contained in:
zonble 2011-10-02 14:20:35 +08:00
parent 6a8eacd0bd
commit cb0d7a82f5
1 changed files with 10 additions and 2 deletions

View File

@ -422,8 +422,16 @@ public:
- (BOOL)inputText:(NSString*)inputText key:(NSInteger)keyCode modifiers:(NSUInteger)flags client:(id)client
{
NSRect textFrame = NSZeroRect;
NSDictionary *attributes = [client attributesForCharacterIndex:0 lineHeightRectangle:&textFrame];
BOOL userVerticalMode = [attributes objectForKey:@"IMKTextOrientation"] && [[attributes objectForKey:@"IMKTextOrientation"] integerValue] == 0;
NSDictionary *attributes = nil;
BOOL userVerticalMode = NO;
@try {
attributes = [client attributesForCharacterIndex:0 lineHeightRectangle:&textFrame];
userVerticalMode = [attributes objectForKey:@"IMKTextOrientation"] && [[attributes objectForKey:@"IMKTextOrientation"] integerValue] == 0;
}
@catch (NSException *e) {
// An exception may raise while using Twitter.app's search filed.
}
NSInteger leftKey = userVerticalMode ? 125 : 124;
NSInteger rightKey = userVerticalMode ? 126 : 123;
NSInteger downKey = userVerticalMode ? 123 : 125;