mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
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:
parent
b92c80ce4f
commit
4af909c207
@ -287,9 +287,12 @@ static GLContext *sharedCtx = nil;
|
|||||||
{
|
{
|
||||||
assert(myDelegate != NULL);
|
assert(myDelegate != NULL);
|
||||||
|
|
||||||
NSText *field = [[self window] fieldEditor:YES forObject:nil];
|
if (sf::priv::WindowImplCocoa::IsTextEvent((void *)theEvent))
|
||||||
[field interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
|
{
|
||||||
[field setString:@""];
|
NSText *field = [[self window] fieldEditor:YES forObject:nil];
|
||||||
|
[field interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
|
||||||
|
[field setString:@""];
|
||||||
|
}
|
||||||
|
|
||||||
myDelegate->HandleKeyDown(theEvent);
|
myDelegate->HandleKeyDown(theEvent);
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,10 @@ public :
|
|||||||
void HandleMouseMove(void *eventRef);
|
void HandleMouseMove(void *eventRef);
|
||||||
void HandleMouseWheel(void *eventRef);
|
void HandleMouseWheel(void *eventRef);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Return whether 'ev' must be considered as a TextEntered event
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
static bool IsTextEvent(void *event);
|
||||||
private :
|
private :
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -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
|
/// /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 priv
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
Loading…
Reference in New Issue
Block a user