mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Move the call to a more centralized method so that it will be called in all cases without repeating code.
This commit is contained in:
parent
fdba6d2be6
commit
3558247662
1 changed files with 28 additions and 12 deletions
|
@ -547,16 +547,29 @@ static id buttonCellClass = nil;
|
|||
return [_cell sound];
|
||||
}
|
||||
|
||||
// Implement 10.7+ radio button behavior
|
||||
- (BOOL) _isRadioButton
|
||||
{
|
||||
return ([[self cell] image] ==
|
||||
[NSImage imageNamed: @"NSRadioButton"]);
|
||||
}
|
||||
|
||||
- (void) mouseDown: (NSEvent *)event
|
||||
- (void) _flipState: (NSButton *)b
|
||||
{
|
||||
[super mouseDown: event];
|
||||
if ([b _isRadioButton])
|
||||
{
|
||||
if ([self action] == [b action] && b != self)
|
||||
{
|
||||
if ([self state] == NSOnState)
|
||||
{
|
||||
[b setState: NSOffState];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _handleRadioStates
|
||||
{
|
||||
if ([self _isRadioButton] == NO)
|
||||
return;
|
||||
|
||||
|
@ -570,20 +583,23 @@ static id buttonCellClass = nil;
|
|||
if ([v isKindOfClass: [NSButton class]])
|
||||
{
|
||||
NSButton *b = (NSButton *)v;
|
||||
if ([b _isRadioButton])
|
||||
{
|
||||
if ([self action] == [b action] && b != self)
|
||||
{
|
||||
if ([self state] == NSOnState)
|
||||
{
|
||||
[b setState: NSOffState];
|
||||
}
|
||||
}
|
||||
}
|
||||
[self _flipState: b];
|
||||
}
|
||||
}
|
||||
END_FOR_IN(subviews);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) sendAction: (SEL)theAction to: (id)theTarget
|
||||
{
|
||||
BOOL flag = [super sendAction: theAction
|
||||
to: theTarget];
|
||||
if (flag == YES)
|
||||
{
|
||||
[self _handleRadioStates];
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue