Re: Enable PopUp if NSTextField > 0
Re: Enable PopUp if NSTextField > 0
- Subject: Re: Enable PopUp if NSTextField > 0
- From: Charilaos Skiadas <email@hidden>
- Date: Tue, 26 Jul 2005 10:03:21 -0500
On Jul 26, 2005, at 4:55 AM, Lorenzo wrote:
Hi,
in my interface window I have a NSTextField containing a decimal
NSNumberFormatter which can accepts values from -10.0 to +10.0
Then I have a NSPopupButton which I want to enable only if the text
field
contains values > 0. So, I subclassed NSTextField and overrided the
method
- (void)textDidChange:(NSNotification*)aNotification
{
[super textDidChange:aNotification];
[aPopUp setEnabled:([self floatValue] > 0)];
}
so I though, I can get the intValue of the text field at any key
pressed,
and if greater than zero I enable the popUp. But since there is a
formatter
in the text field this method doesn't work. I am able to write one
only char
in that field. No more. And
NSText *fieldEditor = [[aNotification userInfo]
objectForKey:@"NSFieldEditor"];
returns nil; Also I have been trying to create a bind between the
popUp and
the textField but it seems to be not so easy. I didn't succeed.
Any suggestion?
Presumably the value of your text field is bound to some ivar in some
object. Just bind the enabled state of the pop-up to the same ivar
through an appropriate value transformer. Haven't tried it myself,
but I see no reason why it should not work.
Best Regards
--
Lorenzo
email: email@hidden
Haris
_______________________________________________
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