Alex Rivera | Logout

Best way to capture key events in NSTextView?

Asked 2008-08-14T16:32:22.957
16

I'm slowly learning Objective-C and Cocoa, and the only way I see so far to capture key events in Text Views is to use delegation, but I'm having trouble finding useful documentation and examples on how to implement such a solution. Can anyone point me in the right direction or supply some first-hand help?

Edit
Report

1 Answer

2

It's important to tell us what you're really trying to accomplish — the higher-level goal that you think capturing key events in an NSTextView will address.

For example, when someone asks me how to capture key events in an NSTextField what they really want to know is how to validate input in the field. That's done by setting the field's formatter to an instance of NSFormatter (whether one of the formatters included in Cocoa or a custom one), not by processing keystrokes directly.

So given that example, what are you really trying to accomplish?

answered 2008-08-15T05:41:51.943

Your Answer