Changes to address issue #151. This should correct behavior of NSRadio buttons in GS and should implement the behavior seen in 10.7+

This commit is contained in:
Gregory John Casamento 2022-08-27 03:46:12 -04:00
parent 645fa46a65
commit a9ca806c2b
2 changed files with 48 additions and 0 deletions

View file

@ -1,3 +1,8 @@
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:

View file

@ -36,6 +36,10 @@
#import "AppKit/NSButtonCell.h"
#import "AppKit/NSEvent.h"
#import "AppKit/NSWindow.h"
#import "AppKit/NSImage.h"
#import "AppKit/NSMatrix.h"
#import "GSFastEnumeration.h"
//
// class variables
@ -543,4 +547,43 @@ static id buttonCellClass = nil;
return [_cell sound];
}
- (void) mouseDown: (NSEvent *)event
{
[super mouseDown: event];
if ([[self superview] isKindOfClass: [NSMatrix class]] == NO)
{
NSImage *i = [[self cell] image];
BOOL isRadio = (i == [NSImage imageNamed: @"NSRadioButton"]);
if (isRadio)
{
NSView *sv = [self superview];
NSArray *subviews = [sv subviews];
FOR_IN(NSView*, v, subviews)
{
if ([v isKindOfClass: [NSButton class]])
{
NSButton *b = (NSButton *)v;
NSImage *image = [[b cell] image];
BOOL flag = (image == [NSImage imageNamed: @"NSRadioButton"]);
if (flag)
{
if ([self action] == [b action] && b != self)
{
if ([self state] == NSOnState)
{
[b setState: NSOffState];
}
}
}
}
}
END_FOR_IN(subviews);
}
}
}
@end