Explorar el Código

Proper Unicode input event on Mac

Ivan Safrin hace 9 años
padre
commit
a85b108728
Se han modificado 1 ficheros con 10 adiciones y 9 borrados
  1. 10 9
      src/view/osx/PolycodeView.mm

+ 10 - 9
src/view/osx/PolycodeView.mm

@@ -701,15 +701,16 @@
 	newEvent.keyCode = keymap[[theEvent keyCode]];	
     core->cocoaEvents.push_back(newEvent);
     
-    CocoaEvent textEvent;
-    textEvent.eventGroup = CocoaEvent::INPUT_EVENT;
-    textEvent.eventCode = InputEvent::EVENT_TEXTINPUT;
-    
-    NSString *chars = [theEvent characters];
-    NSUInteger numChars = [chars length];
-	textEvent.text = [chars UTF8String];
-	if(numChars > 0 && !((unsigned char) textEvent.text[0] < ' ' || textEvent.text[0] == 127) && textEvent.text[0] > 0) {
-		core->cocoaEvents.push_back(textEvent);
+    if(!([theEvent modifierFlags] & NSAlternateKeyMask || [theEvent modifierFlags] & NSCommandKeyMask || [theEvent modifierFlags] & NSControlKeyMask)) {
+	    CocoaEvent textEvent;
+	    textEvent.eventGroup = CocoaEvent::INPUT_EVENT;
+	    textEvent.eventCode = InputEvent::EVENT_TEXTINPUT;
+		textEvent.text = [[theEvent characters] UTF8String];
+		if(textEvent.text.length() > 0) {
+			if((unsigned char)textEvent.text.c_str()[0] != 13 && (unsigned char)textEvent.text.c_str()[0] != 239 && (unsigned char)textEvent.text.c_str()[0] != 127 && (unsigned char)textEvent.text.c_str()[0] != 27) {
+				core->cocoaEvents.push_back(textEvent);
+			}
+		}
 	}
 	
 	core->unlockMutex(core->eventMutex);