From e9a201af21c4e9965189a1005f7a2ca6c17b5cb1 Mon Sep 17 00:00:00 2001 From: mantognini Date: Sat, 5 Feb 2011 14:15:31 +0000 Subject: [PATCH] OSX, fixed arrow keys creating TextEntred event. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1789 4e206d99-4929-0410-ac5d-dfc041789085 --- src/SFML/Window/OSX/SFOpenGLView.mm | 16 ++++++++++++++-- src/SFML/Window/OSX/WindowImplCocoa.hpp | 2 +- src/SFML/Window/OSX/WindowImplCocoa.mm | 2 +- src/SFML/Window/OSX/WindowImplDelegateProtocol.h | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/SFML/Window/OSX/SFOpenGLView.mm b/src/SFML/Window/OSX/SFOpenGLView.mm index 691415348..7a078de71 100644 --- a/src/SFML/Window/OSX/SFOpenGLView.mm +++ b/src/SFML/Window/OSX/SFOpenGLView.mm @@ -359,8 +359,20 @@ if (myUseKeyRepeat || ![theEvent isARepeat]) myRequester->KeyDown([theEvent keyCode], [theEvent modifierFlags]); - if ((myUseKeyRepeat || ![theEvent isARepeat]) && [[theEvent characters] length] > 0) - myRequester->TextEntred([[theEvent characters] characterAtIndex:0]); + if ((myUseKeyRepeat || ![theEvent isARepeat]) && [[theEvent characters] length] > 0) { + /// From NSEvent.h : + /* + * Unicodes we reserve for function keys on the keyboard, + * OpenStep reserves the range 0xF700-0xF8FF for this purpose. + * The availability of various keys will be system dependent. + */ + /// And 0x35 is the Escape key. + unichar ch = [[theEvent characters] characterAtIndex:0]; + if ([theEvent keyCode] != 0x35 && + (ch < 0xf700 || ch > 0xf8ff)) { + myRequester->TextEntered(ch); + } + } } diff --git a/src/SFML/Window/OSX/WindowImplCocoa.hpp b/src/SFML/Window/OSX/WindowImplCocoa.hpp index 538da0d20..5af94773f 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.hpp +++ b/src/SFML/Window/OSX/WindowImplCocoa.hpp @@ -102,7 +102,7 @@ public: void MouseMovedOut(void); void KeyDown(unsigned short keycode, unsigned int modifierFlags); void KeyUp(unsigned short keycode, unsigned int modifierFlags); - void TextEntred(Uint32 charcode); + void TextEntered(Uint32 charcode); static Key::Code NSKeyCodeToSFMLKeyCode(unsigned short rawchar); diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index 79a99bbf0..6aa68a196 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -281,7 +281,7 @@ void WindowImplCocoa::KeyUp(unsigned short keycode, unsigned int modifierFlags) //////////////////////////////////////////////////////////// -void WindowImplCocoa::TextEntred(Uint32 charcode) +void WindowImplCocoa::TextEntered(Uint32 charcode) { Event event; event.Type = Event::TextEntered; diff --git a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h index 54ff54454..567924611 100644 --- a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h +++ b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h @@ -54,7 +54,7 @@ namespace sf { /// MouseDownAt, MouseUpAt, MouseMovedAt, MouseWheelScrolledAt, /// MouseMovedIn, MouseMovedOut /// -/// KeyDown, KeyUp, TextEntred +/// KeyDown, KeyUp, TextEntered /// /// Note : Joystick are not bound to a view or window /// thus they're not managed by a class implementing this protocol.