Why is this Button setState not working?
@implementation SLTButton
- (void) setState:(NSInteger)state {
[super setState:state];
int times;
for (times = 0; times = 100; times = times + 1){
if ((state == NSOnState) && ([_ButtonPart2 isTransparent])) {
[_ButtonPart1 setTitle:@"1Blue"];
[_ButtonPart2 setTitle:@""];
}else if ((state == NSOnState)) {
[_ButtonPart1 setTitle:@""];
[_ButtonPart2 setTitle:@"2Blue"];
}else if ((state == NSOffState) && ([_ButtonPart2 isTransparent])) {
[_ButtonPart1 setTitle:@"1Green"];
[_ButtonPart2 setTitle:@""];
}else if ((state == NSOffState)) {
[_ButtonPart1 setTitle:@""];
[_ButtonPart2 setTitle:@"2Green"];
}else if ((state == NSMixedState) &&([_ButtonPart2 isTransparent])){
[_ButtonPart1 setTitle:@"1Yellow"];
[_ButtonPart2 setTitle:@""];
}else if ((state == NSMixedState)) {
[_ButtonPart1 setTitle:@""];
[_ButtonPart2 setTitle:@"2Yellow"];
}
}
}
@end
I made 4 IBOutlet of the buttons and the buttonCell and than i connected them to the 2 separate buttons. so buttonPart1 is one button and buttonPart2 is the other button
but how come this code is not work it wont even set a value to the one that are not transparent. (im going work on the transparent part after this).
here is the project files:
theProject.zip 24kb file
example:
(button) (button) none clicked
(1Blue) ( ) part1 clicked but part2 is transparent
(1Green) ( ) part1 clicked but part2 is still transparent
(1Yellow) ( ) part1 clicked but part2 is still transparent
than the opposite
you think you can help me out?
Hi
I'm not sure I've understood your intention here, however I've tweaked and fixed a simple bug which caused "one infinite loop". I've added a button "button" and when you press that, your state code is run and seems to be doing something sensible. Here's my version: http://clanmills.com/files/theProject.zip