Bind button title to Boolean

2008-10-27 Thread Trygve Inda
How can I bind a button title to a Boolean but have a custom title for each
state? For example, I have a BOOL  isRunning, if YES, my button should read
Stop Running else Start Running.

I can't really do this with an alternate title since when the button is
pushed and temporarily held down, the title should not change as it is a
normal push pill button.

Thanks,

Trygve


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Bind button title to Boolean

2008-10-27 Thread Trygve Inda
 How can I bind a button title to a Boolean but have a custom title for each
 state? For example, I have a BOOL  isRunning, if YES, my button should read
 Stop Running else Start Running.
 
 I can't really do this with an alternate title since when the button is
 pushed and temporarily held down, the title should not change as it is a
 normal push pill button.

I know I can write a value transformer, but is there a simple way to do such
a two state button title in IB and just provide it my isRunning method? It
seems like a common enough default situation.

T.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Bind button title to Boolean

2008-10-27 Thread Steve Christensen

On Oct 27, 2008, at 3:32 AM, Trygve Inda wrote:

How can I bind a button title to a Boolean but have a custom title  
for each
state? For example, I have a BOOL  isRunning, if YES, my button  
should read

Stop Running else Start Running.

I can't really do this with an alternate title since when the  
button is
pushed and temporarily held down, the title should not change as it  
is a

normal push pill button.


How about something like this? Whenever isRunning changes, it  
triggers an update of the button's title.



+ (void) initialize
{
...

[self setKeys:[NSArray arrayWithObject:@isRunning]
triggerChangeNotificationsForDependentKey:@buttonTitle];

...
}


- (NSString*) buttonTitle
{
return [self isRunning] ? @Stop Running : @Start Running;
}


- (BOOL) isRunning
{
return _isRunning;
}

- (void) setIsRunning:(BOOL)isRunning
{
[self willChangeValueForKey:@isRunning];
_isRunning = isRunning;
[self didChangeValueForKey:@isRunning];
}

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]