Handling a return or enter key event on an edit text control
In my game editor I'm trying to get an edit text control and a little arrows control to work together the way they do on the clock control and I'm having a bit of trouble.
Basically I can't figure out how to find out if the return or enter key is pressed while the edit text control is selected. What kind of event handler do I use?
Is there a simple way of getting a control like this up and running?
Basically I can't figure out how to find out if the return or enter key is pressed while the edit text control is selected. What kind of event handler do I use?
Is there a simple way of getting a control like this up and running?
Use Cocoa... trying to use Carbon to make a standard Mac UI is completely insane.
Yes well I thought you might say that.
But it's a bit far gone to switch to Cocoa now, at least I'd like to try to get this working in Carbon first before I take that big of a step. Surely it is possible to have a standard edit text control work the way you'd expect it to using Carbon?
But it's a bit far gone to switch to Cocoa now, at least I'd like to try to get this working in Carbon first before I take that big of a step. Surely it is possible to have a standard edit text control work the way you'd expect it to using Carbon?
Of course, but the chances anyone actually knows /how/ are slim

...or anyone actually *remembering* how

I'm not actually sure if this works, because i never used EditText fields with Carbon before. But my suggestion is that you could use a normal event loop to check for the return key and then verify with "GetKeyboardFocus(...)" if the EditText field is selected.
monteboyd Wrote:Basically I can't figure out how to find out if the return or enter key is pressed while the edit text control is selected. What kind of event handler do I use?If you can require 10.3 or later, register for a { kEventClassTextField, kEventTextAccepted } event (HIView.h). This will be sent when the user hits enter/return and the focus is in an edit field, combo box, or search field (or when the field had the focus and loses it: i.e., it's a generic "user has accepted this value" event for text views).
If you have to support pre-10.3, you can attach a { kEventClassKeyboard, kEventRawKeyDown } handler to the control with InstallControlEventHandler and then trigger your action when you see the keystroke come in.
OneSadCooki Wrote:Use Cocoa... trying to use Carbon to make a standard Mac UI is completely insane.That's nonsense.
Thanks elerion, I attached a raw key event to the edit text box and then use GetKeyboardFocus and that works. However I might try dair's suggestion as that would mean not having to check for the return key, the enter key, the tab key etc manually.
Thanks guys.
Thanks guys.
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Full Screen Event Handling | kodex | 4 | 6,639 |
Jun 27, 2008 08:37 PM Last Post: OneSadCookie |
|
Return style | Coin | 13 | 7,692 |
Apr 22, 2006 12:11 AM Last Post: OneSadCookie |
|
Event Handling (Keyboard and Mouse) | bwalters | 6 | 9,886 |
Mar 12, 2006 08:17 PM Last Post: OneSadCookie |
|
State Tables and Event Handling | geolycosa | 1 | 3,521 |
Aug 29, 2005 12:58 PM Last Post: ThemsAllTook |
|
Getting text from a window text field | mars | 7 | 7,080 |
Mar 26, 2005 06:06 PM Last Post: OneSadCookie |