Re: teaching a game to "speak" different languages
Re: teaching a game to "speak" different languages
- Subject: Re: teaching a game to "speak" different languages
- From: Aki Inoue <email@hidden>
- Date: Thu, 1 Aug 2002 11:19:59 -0700
Tobias,
The text input system in AppKit requires the responder receiving the
input to be the first responder.
Maybe you can create an NSWindow instance that's only used for the text
input; then, override -[NSApplication keyWindow] to always return the
window. You could make the temp window to return the NSApp as its
first responder.
Aki
On 2002.8.1, at 10:49 AM, tobias wrote:
Thanks for the start. Unfortunately, I'm bypassing the event chain,
and Appkit hierarchy for a higher framerate. In fact, when in
fullscreen mode, there isn't even a window.
The following might show off my lack of obj-c knowledge :)
Since NSApplication is derived from NSResponder it seemed possible
that I may be able to get by with doing the following.
calling [NSApp interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
and then implementing insertText as a category to NSApplication. This
seems that it should be able to work. I can send a message to [NSApp
insertText] in the source and everything is good. Unfortunately, the
insertText message produced by interpretKeyEvents seems to be getting
lost.
Any more suggestions or know why this might not be working?
Thanks.
On Thursday, August 1, 2002, at 01:09 AM, Greg Titus wrote:
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
-------------------
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.
_______________________________________________
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.