mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 21:40:36 +00:00
Merge pull request #152 from gnustep/issue151_nsradiobutton_behavior
This commit is contained in:
commit
7a42b1d04c
3 changed files with 78 additions and 0 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2022-09-01 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/NSButtonCell.m: Move method to detect if button is a
|
||||
radio button to this class (- _isRadio)
|
||||
* Source/NSButton.m: Add method to check current state of button
|
||||
clicked and flip other buttons to off (-_handleRadioStates)
|
||||
|
||||
2022-08-27 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/NSButton.m: Fix to address issue #151, NSRadio button
|
||||
behavior on 10.7 should now be implemented.
|
||||
|
||||
2022-08-09 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/AppKit/NSPredicateEditorRowTemplate.h:
|
||||
|
|
|
@ -37,11 +37,17 @@
|
|||
#import "AppKit/NSEvent.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
|
||||
#import "GSFastEnumeration.h"
|
||||
|
||||
//
|
||||
// class variables
|
||||
//
|
||||
static id buttonCellClass = nil;
|
||||
|
||||
@interface NSButtonCell (_NSButton_Private_)
|
||||
- (BOOL) _isRadio;
|
||||
@end
|
||||
|
||||
/**
|
||||
TODO Description
|
||||
*/
|
||||
|
@ -543,4 +549,49 @@ static id buttonCellClass = nil;
|
|||
return [_cell sound];
|
||||
}
|
||||
|
||||
// Implement 10.7+ radio button behavior
|
||||
- (void) _flipState: (NSButton *)b
|
||||
{
|
||||
if ([[b cell] _isRadio])
|
||||
{
|
||||
if ([self action] == [b action] && b != self)
|
||||
{
|
||||
[b setState: NSOffState];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _handleRadioStates
|
||||
{
|
||||
if ([[self cell] _isRadio] == NO)
|
||||
return;
|
||||
else
|
||||
{
|
||||
NSView *sv = [self superview];
|
||||
NSArray *subviews = [sv subviews];
|
||||
|
||||
FOR_IN(NSView*, v, subviews)
|
||||
{
|
||||
if ([v isKindOfClass: [NSButton class]])
|
||||
{
|
||||
NSButton *b = (NSButton *)v;
|
||||
[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
|
||||
|
|
|
@ -1922,4 +1922,19 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
// Implement 10.7 NSRadio button behavior...
|
||||
|
||||
- (BOOL) _isRadio
|
||||
{
|
||||
return ([self image] == [NSImage imageNamed: @"NSRadioButton"]);
|
||||
}
|
||||
|
||||
- (NSInteger) nextState
|
||||
{
|
||||
if ([self _isRadio] && [self state] == NSOnState)
|
||||
return [self state];
|
||||
|
||||
return [super nextState];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue