• 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
insertText: without a NSWindow/NSView (or: Unicode input without NSView/Window)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Subject: insertText: without a NSWindow/NSView (or: Unicode input without NSView/Window)
  • From: Adam Zegelin <email@hidden>
  • Date: Wed, 30 Jan 2008 19:05:31 +1100

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: insertText: without a NSWindow/NSView (or: Unicode input without NSView/Window)
      • From: Sam Stigler <email@hidden>
    • Re: insertText: without a NSWindow/NSView (or: Unicode input without NSView/Window)
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: The mouse is where?
  • Next by Date: Re: Best way to notify the Controller when one Array object value is changed
  • Previous by thread: Re: Sample project "Cocoa Sliders": some questions about API usage
  • Next by thread: Re: insertText: without a NSWindow/NSView (or: Unicode input without NSView/Window)
  • Index(es):
    • Date
    • Thread