• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: teaching a game to "speak" different languages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: teaching a game to "speak" different languages


  • Subject: Re: teaching a game to "speak" different languages
  • From: Greg Titus <email@hidden>
  • Date: Wed, 31 Jul 2002 23:09:39 -0700

Hi Tobias,

The problem you are having is that -keyDown: is to low of a level to get text when there is a foreign language input manager active. (Because many of these languages can require more than one keystroke to input a single character.)

What you need to do is have your -keyDown: method call -interpretKeyEvents:, which will invoke the active input manager and create the correct string for you, then call you back with the -insertText: method. This is documented in NSResponder.

So the code would look like:

- (void)keyDown:(NSEvent *)theEvent;
{
// handle any keys that you want to handle directly, instead of as text input...
// ...
// then for any left over:
[self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
}

- (void)insertText:(id)aString;
{
NSLog(@"%@", aString);
}

Hope this helps,
-Greg

On Wednesday, July 31, 2002, at 10:07 PM, tobias ford... wrote:

First, I'm not a localization expert, so I might have some of the terminology incorrect. Second, I searched the archives and googled apples site, but didn't see anything that jumped out at me (I'm also not sure what I'm even looking for).

I'm needing to grab the actual unicode values generated from a user in our game. For example, if a user is chatting in Korean, then everything that avatar says needs to appear in Korean over their head. We've already got it so that the Mac can "listen" to other languages from windows, but I'm having problems getting the Mac to "speak" back. I was under the impression that something very similar to the below would work:

- (void)keyDown:(NSEvent *)theEvent
{
int numberOfKeys = [[theEvent characters] length];
int index = 0;
for (index = 0; index < numberOfKeys; ++index) {
unichar character = [[theEvent characters] characterAtIndex:index];
NSLog (@"%d\n", character);
}
}

The above doesn't work using the "IME" language menu, or even when using an arabic character set from the keyboard. The first generates nothing. This makes me believe that I need to be looking at some other event. The second though, seems odd because the characters are actually generated from the keyboard, but all that I'm seeing are ASCII values.

Can someone either share the secret or point me to the correct documents to take a look at? Thanks, I really appreciate it bc we're on a very tight deadline right now.

Please cc as I'm on digest. Thanks again.

-------------------
Tobias Ford...
email@hidden email@hidden
-------------------
Senior Software Engineer @ WolfPack Studios
www.wolfpackstudios.com www.shadowbane.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: cocoa-dev digest, Vol 2 #1031 - 16 msgs
  • Next by Date: Re: content inside sender
  • Previous by thread: Re: cocoa-dev digest, Vol 2 #1031 - 16 msgs
  • Next by thread: Re: content inside sender
  • Index(es):
    • Date
    • Thread