• 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
Using -interpretKeyEvents in NSTextView to interpret key events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using -interpretKeyEvents in NSTextView to interpret key events


  • Subject: Using -interpretKeyEvents in NSTextView to interpret key events
  • From: Kuon <email@hidden>
  • Date: Sat, 28 Jul 2007 17:41:01 +0200

Hello,

I am working on a game, everything is drawn with OpenGL and the game use 100% plain C and lua for UI. This approach give me a good portability (and I love C).

Anyway, my app has some event entry points, I was able to extra all the info (From NSEvent) for mouse events but for key events, I have some troubles.

Let me explain.

(We are in - (void)keyDown:(NSEvent *)event)

My application has two entry points for keyboard events:

App_keyDown(code) and App_textInput(code)

Key down is used to pilot your ship, to fire your weapon or anything else, I send a converted [event keyCode] to it and it works fine.

Now, the problem is with App_textInput, code is an UCS4 code to be send to the app. I was able to get correct code with

[[event characters] characterAtIndex:0]

But, I can't support composition (´+ e = é), or japanese input (I'll need that one).

For composition, I was able to workaround with:

[fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]]; // fieldEdit is an NSTextView

It change [event characters], so when I input ´+e I got é and not e.

Now, there is two things that are not working, marked characters and japanese input.

I thought about changing App_textInput(anUTFString, isMarkedText), this is not the problem, I have total control after the entry point.

The problem is how to get the piece of information.

[fieldEdit hasMarkedText] is always FALSE, whenever I press ´ or ^ or any other composition key.

What I want, is, each time I press a key, I want to send to App_textInput, the string to add and if it is marked text, if it is, it will get replaced by the next App_textInput. Like when I enter japanese, I will have the string I am typing getting sent to my app, and at the end, when I press enter, it send it again with isMarkedText false and that time, my text backend will print it non highlighted.

I was thinking of using NSTextView for this, but I'm very new to Cocoa and I'm a bit lost.

Regards


-- Kuon

"Don't press that button."
http://goyman.com/
Blog: http://kuon.goyman.com/



_______________________________________________

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: Using -interpretKeyEvents in NSTextView to interpret key events
      • From: Martin Wierschin <email@hidden>
    • Re: Using -interpretKeyEvents in NSTextView to interpret key events
      • From: arri <email@hidden>
    • Re: Using -interpretKeyEvents in NSTextView to interpret key events
      • From: Kuon <email@hidden>
  • Prev by Date: key-value support for Objective-C "class" variables?
  • Next by Date: Re: Sending message to Objective-C object from C file
  • Previous by thread: Re: key-value support for Objective-C "class" variables?
  • Next by thread: Re: Using -interpretKeyEvents in NSTextView to interpret key events
  • Index(es):
    • Date
    • Thread