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: tobias <email@hidden>
- Date: Thu, 1 Aug 2002 19:01:46 -0500
So I've created a small sample app (for learning the system) that
responds correctly to the keydown message on a subclassed nswindow when
using the keyboard. When using a foreign language input manager, no
keyboard events are generated. The only other sample app to use
interpretKeyEvents is Sketch which also suffers from this same problem.
TextEdit works as expected, but here I'm assuming the event is handled
somewhere in the document heirarchy. Is this correct? I know that the
foreign language input manager posts it's event as a NSSystemDefined
event type. This makes me wonder how anyone really gets these
characters into their non-document based applications. Any answers?
On Thursday, August 1, 2002, at 01:19 PM, Aki Inoue wrote:
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.