Re: Preferences....
Re: Preferences....
- Subject: Re: Preferences....
- From: R T <email@hidden>
- Date: Tue, 8 Mar 2005 07:16:30 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Here's what I've tried, to accomplish this:
1. How do I setup an NSTextField to act on the
returnKey and use its floatValue to change a
Preference?
The NSTextField has AppController as its delegate.
The AppController has the NSTextField as its outlet.
To the AppController code I added this:
- (void)awakeFromNib
{
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(textDidChange:)
name:NSControlTextDidChangeNotification
object:nil];
NSLog(@"Registered with notification
center.");
}
- (void)textDidChange:(NSNotification *)aNotification
{
NSLog(@"aNotification object: %@",
[aNotification
object ]);
}
---------------------
The Log reads...2005-03-07 23:02:41.102 Chromatic
Space[934] aNotification object: <NSTextField:
0x345fd0>
How do I go from this to the float value in the
NSTextField?
---------------------
Thanks
Rick T.
--- Shawn Erickson <email@hidden> wrote:
>
> On Mar 7, 2005, at 3:12 PM, R T wrote:
>
> > 1. How do I setup an NSTextField to act on the
> > returnKey and use its floatValue to change a
> > Preference?
>
> Review the docs on NSTextField, its delgates and
> NSUserDefaults.
>
> > 2. Can an NSButton be set up to trigger the
> Action at
> > a target AppController to retrieve a Preference
> and
> > display it in an NSTextField.
>
> Yes it can but not sure why you need to have a
> button to trigger this
> when it can be done at initialization time and on
> notification of a
> change.
>
> Anyway a quick run down... setup the button to
> target your app
> controller instance and a particular action. Then
> have that action use
> NSUserDefaults to read in what is needed and finally
> set the
> NSTextFields value (using an outlet pointed at it).
>
> > This seemed like such an easy thing to do but now
> its
> > like I'm trying to create a lightbulb from
> scratch...a
> > few well written lines would be of great help.
>
> It is easy but one part of it requires using IB to
> either setup the
> target/action or bind things for the button (or do
> you really want to
> do it programatically) as well as setting up an
> outlet to the text
> field.
>
> If you used bindings then all you would need to do
> is bind the text
> field value to the user defaults control using the
> key of the
> preference in question using IB.
>
> -Shawn
>
>
__________________________________
Celebrate Yahoo!'s 10th Birthday!
Yahoo! Netrospective: 100 Moments of the Web
http://birthday.yahoo.com/netrospective/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden