Fixed issue with beep produced by Esc and functions keys.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1142 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
ceylo 2009-06-14 14:36:11 +00:00
parent b92c80ce4f
commit 4af909c207
3 changed files with 29 additions and 22 deletions

View File

@ -287,9 +287,12 @@ static GLContext *sharedCtx = nil;
{
assert(myDelegate != NULL);
if (sf::priv::WindowImplCocoa::IsTextEvent((void *)theEvent))
{
NSText *field = [[self window] fieldEditor:YES forObject:nil];
[field interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
[field setString:@""];
}
myDelegate->HandleKeyDown(theEvent);
}

View File

@ -108,6 +108,10 @@ public :
void HandleMouseMove(void *eventRef);
void HandleMouseWheel(void *eventRef);
////////////////////////////////////////////////////////////
/// Return whether 'ev' must be considered as a TextEntered event
////////////////////////////////////////////////////////////
static bool IsTextEvent(void *event);
private :
////////////////////////////////////////////////////////////

View File

@ -511,6 +511,25 @@ void WindowImplCocoa::HandleMouseWheel(void *eventRef)
}
}
////////////////////////////////////////////////////////////
/// Return whether 'ev' must be considered as a TextEntered event
////////////////////////////////////////////////////////////
bool WindowImplCocoa::IsTextEvent(void *eventRef)
{
NSEvent *event = (NSEvent *)eventRef;
bool res = false;
if (event && [event type] == NSKeyDown && [[event characters] length]) {
unichar code = [[event characters] characterAtIndex:0];
// Codes from 0xF700 to 0xF8FF are non text keys (see NSEvent.h)
// 0x35 is the Escape key
if ([event keyCode] != 0x35 && (code < 0xF700 || code > 0xF8FF))
res = true;
}
return res;
}
////////////////////////////////////////////////////////////
/// /see sfWindowImpl::Display
@ -797,25 +816,6 @@ static Key::Code KeyForUnicode(unsigned short uniCode)
}
////////////////////////////////////////////////////////////
/// Return whether 'ev' must be considered as a TextEntered event
////////////////////////////////////////////////////////////
static bool IsTextEvent(NSEvent *event)
{
bool res = false;
if (event && [event type] == NSKeyDown && [[event characters] length]) {
unichar code = [[event characters] characterAtIndex:0];
// Codes from 0xF700 to 0xF8FF are non text keys (see NSEvent.h)
if (code < 0xF700 || code > 0xF8FF)
res = true;
}
return res;
}
} // namespace priv
} // namespace sf