From a266a0a446cd230edbc1574a20c61fe33162d1cb Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Wed, 6 May 2015 20:26:55 +0900 Subject: [PATCH] Generate correct wxEVT_CHAR for non-BMP characters in wxOSX. Since [NSString characterAtIndex:] return UTF-16 values, it can't be used as a "character", convert the entire NSString to wxString and iterate over it to obtain the real characters that should be sent in wxEVT_CHAR events. Closes #16979. --- src/osx/cocoa/window.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 3cd9d2cd14..f37086772a 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -2730,7 +2730,10 @@ bool wxWidgetCocoaImpl::DoHandleCharEvent(NSEvent *event, NSString *text) int length = [text length]; if ( peer ) { - for (NSUInteger i = 0; i < length; ++i) + const wxString str = wxCFStringRef([text retain]).AsString(); + for ( wxString::const_iterator it = str.begin(); + it != str.end(); + ++it ) { wxKeyEvent wxevent(wxEVT_CHAR); @@ -2749,7 +2752,7 @@ bool wxWidgetCocoaImpl::DoHandleCharEvent(NSEvent *event, NSString *text) wxevent.m_rawCode = 0; wxevent.m_rawFlags = 0; - unichar aunichar = [text characterAtIndex:i]; + const wxChar aunichar = *it; #if wxUSE_UNICODE wxevent.m_uniChar = aunichar; #endif