Fix annoying sound alert when escape is pressed on OS X

This commit is contained in:
Marco Antognini 2011-07-03 22:29:34 +02:00
parent c850d3b111
commit 1066caa771

View File

@ -448,7 +448,13 @@ sf::Key::Code NonLocalizedKeys(unsigned short keycode);
}
}
if (myUseKeyRepeat || ![theEvent isARepeat]) {
if ((myUseKeyRepeat || ![theEvent isARepeat]) && [[theEvent characters] length] > 0) {
// Ignore escape key and non text keycode. (See NSEvent.h)
// They produce a sound alert.
unichar code = [[theEvent characters] characterAtIndex:0];
if ([theEvent keyCode] != 0x35 && (code < 0xF700 || code > 0xF8FF)) {
// Let's see if its a valid text.
NSText* text = [[self window] fieldEditor:YES forObject:self];
[text interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
@ -461,6 +467,7 @@ sf::Key::Code NonLocalizedKeys(unsigned short keycode);
[text setString:@""];
}
}
}
}