Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Oats

macrumors regular
Original poster
Jan 8, 2003
194
1
New York
hello,
i am trying to learn to use xcode and interface builder and all that. i know c++ very well, and know windows programming pretty well. i am having trouble finding out where to start with this xcode stuff.

so i am starting with some sample code and trying to make a simple change.

the ToolbarSample code is here:
http://developer.apple.com/samplecode/ToolbarSample/index.html

is it basically a NSTextView with a simple toolbar.

what I want to do is filter some keydown events, and when "enter" key is hit, insert some text to the NSTextView. do i need to subclass the NSTextView? or do i just need to set up a first responder somehow? how do i catch the key events?

thanks for any help!
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
So what has input focus when you want to capture events? The Text View? If that is the case then subclassing that and overriding the various event message handlers would work as long as you passed them on to the superclass.

A slightly cleaner way that will work as long as your window is the key window would be to create a new NSResponder subclass and insert that near the top of the responder chain. If inserted in the correct place you should get key events in that window no matter what control has focus.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.