Japanese input

Hi Jules,

I’m trying to input Japanese character using TextEditor/Label components on Mac, but I can input only first one letter.

As for Japanese, two characters or more might be input. Probably, Korean and Chinese also have the same situation. Therefore I added the following changes.

juce_mac_Windowing.cpp

OSStatus handleTextInputEvent (EventRef theEvent)
{
#if	0	//	Original code
	UniChar uc;
	GetEventParameter (theEvent, kEventParamTextInputSendText, typeUnicodeText, 0, sizeof (uc), 0, &uc);

	EventRef originalEvent;
	GetEventParameter (theEvent, kEventParamTextInputSendKeyboardEvent, typeEventRef, 0, sizeof (originalEvent), 0, &originalEvent);

	return handleKeyEvent (originalEvent, (juce_wchar) uc);

#else	//	Handle input more than 2 characters, such as Japanese, Chinese, Korean and so on...
	UniChar *text;
	UInt32  actualSize;
	GetEventParameter (theEvent, kEventParamTextInputSendText, typeUnicodeText, NULL, 0, &actualSize, NULL);
	text = (UniChar*) NewPtr(actualSize);
	GetEventParameter (theEvent, kEventParamTextInputSendText, typeUnicodeText, NULL,  actualSize, NULL, text);
				
	EventRef originalEvent;
	GetEventParameter (theEvent, kEventParamTextInputSendKeyboardEvent, typeEventRef, 0, sizeof (originalEvent), 0, &originalEvent);

	UniCharCount charCount = actualSize / sizeof( UniChar );
	OSStatus result = eventNotHandledErr;
	for (int i = 0; i < charCount; ++i)
	{
		if (handleKeyEvent (originalEvent, (juce_wchar) text[i]) != eventNotHandledErr)
			result = noErr;
	}

	return result;
#endif
}

It seems to work properly. If possible, I would like you to fix the problem in future editions.

Programming Environment:
Mac OS X 10.5.2 / Xcode 2.5 / JUCE v1.46 from SVN

Best regards,
Jazzunko

Nice one, thanks, I’ll take a look at that very soon. It’s very difficult for me to test anything involving Japanese keyboards or characters!

Thank you, I’m looking forward to getting the version, and I’ll keep checking this improved version.
:smiley: