Re: Identifying NSTextViews
Re: Identifying NSTextViews
- Subject: Re: Identifying NSTextViews
- From: Rippit the Ogg Frog <email@hidden>
- Date: Tue, 28 Jul 2009 22:38:16 -0700
This worked perfectly, however the window delegate method I needed in my
particular case was windowDidResignKey, because I'm not actually closing
the window when the user dismisses it, but calling orderOut:.
Also NSTextView's string method returns a pointer to its internal
buffer, so one should copy it and use the copy.
Thanks for all your help everyone.
Andy Lee wrote:
In the list archives I saw a mention of creating a separate outlet in
the controller for each NSTextView, with each view being connected to
a separate outlet. I think that would work fine for me but I don't
quite understand how to go about it - I haven't done much Cocoa
programming before.
In the header of your window controller class, declare instance
variables like this:
IBOutlet NSTextView * textViewOne;
IBOutlet NSTextView * textViewTwo;
... etc. ...
Save the file and return to Interface Builder. The new outlets will
show up and you'll be able to make connections from your window
controller to the various text views.
==> NOTE: make sure to connect to the text views and not the scroll
views that enclose them.
My objective is just to capture the text from each view when the
window is dismissed, so there could be another way to do what I want
without using a delegate. It's not necessary for me to get called for
every character the user types.
Implement the window delegate method windowWillClose:. Your window
controller is probably already the window's delegate, but if it isn't,
make that connection in IB. Then in windowWillClose:, collect the data
from your six text views using [textViewOne string], [textViewTwo
string], etc.
--Andy
--
Rippit the Ogg Frog
email@hidden
http://www.oggfrog.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