Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: insertText: without a NSWindow/NSView (or: Unicode input without NSView/Window)



Hey,

I don't have any experience with this, but have you tried using Quartz Event Services (http://developer.apple.com/documentation/Carbon/Reference/QuartzEventServicesRef/ ) to handle your keyboard events? The two functions I'm thinking of are CGEventTapCallBack and CGEventKeyboardGetUnicodeString (which hopefully wlll interpret events that are from other input sources).

Sam


On Jan 30, 2008, at 12:05 AM, Adam Zegelin wrote:

Hey,

I'm working on porting a Win32 game to Mac OS X. It has been decided by higher up to start supporting unicode text input. The platform implementation is required to pass a unichar to game engine whenever a printable key is pressed (or inputed by some other method, such as an input manager)

The game can run in a window (NSWindow + a NSOpenGLView) or fullscreen (using CGL and CG) hence I can't rely on any methods of text input that require a window.

Currently I override NSApplications' sendEvent method and attempt to handle events myself. Any unhandled events are processed with [super sendEvent:event]. My event handler is implemented in my controller object. It checks if the keyWindow is the game window, otherwise I don't handle the event. If the game is fullscreen, I always handle the event.

If the event is a key up/down and is not a repeat, I forward it onto the game engine for processing as a key up or down message (respectively). These messages contain the raw keycode translated into an engine specific code.

Now here comes my problem: I need to send unicode input messages to the game engine if the key(s) pressed are in-fact printable. For example:

Escape key (non-printable): KeyDown...KeyUp
"A" key: KeyDown...unicode input...(unicode input... — if the user is holding down the key)...KeyUp


I can do single keys fine, I just send the [[event characters] characterAtIndex:0] off to the game engine. But things composite characters like option-e + e (é) do not work. [[event characters] characterAtIndex:0] just returns "e". Non-composite keys like option- w (∑) do work correctly.

Also, since I'm only inspecting the event stream, other systems of input such as the Character Palette don't work with the application.

I've tried making my controller a subclass of NSResponder and calling interpretKeyEvents: with the keyDown event I receive and then implementing insertText:. Again, this only catches non- composite characters and does not support other input methods.

I've read the documentation over and over and unless I'm missing something cannot locate any information that explains how to do input without a window and a responder chain. I've also tried google without any luck. Again, this needs to support fullscreen and windowed mode. And I'd prefer to not use some kludge like making a window fullscreen.

I'm developing with Xcode 3 and Cocoa (obviously), and whatever method I use needs to support 10.4 minimum.

	Any suggestions?

Regards,
Adam





	
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >insertText: without a NSWindow/NSView (or: Unicode input without NSView/Window) (From: Adam Zegelin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.