Merge pull request #145 from gnustep/cell_resp2

Cell responder
This commit is contained in:
Fred Kiefer 2022-03-24 22:46:14 +01:00 committed by GitHub
commit 80140c6336
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2022-03-22 Riccardo Mottola <rm@gnu.org>
* Source/NSImageCell.m: subclass initImageCell, so that
RefusesFirstResponder can be set, matching Mac.
2022-02-26 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSPopUpButtonCell.m(setMenu:): Select the first item of

View file

@ -2,7 +2,7 @@
<abstract>The image cell class</abstract>
Copyright (C) 1999, 2005 Free Software Foundation, Inc.
Copyright (C) 1999, 2005-2022 Free Software Foundation, Inc.
Author: Jonathan Gapen <jagapen@smithlab.chem.wisc.edu>
Date: 1999
@ -51,7 +51,7 @@
{
if (self == [NSImageCell class])
{
[self setVersion: 1];
[self setVersion: 2];
}
}
@ -63,6 +63,15 @@
return [self initImageCell: nil];
}
- (id) initImageCell: (NSImage*)anImage
{
if (self = [super initImageCell: anImage])
{
[self setRefusesFirstResponder: YES];
}
return self;
}
- (void) setImage:(NSImage *)anImage
{
[super setImage:anImage];
@ -344,7 +353,13 @@ yBottomInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
else
{
NSInteger tmp;
NSUInteger version = [aDecoder versionForClassName: @"NSImageCell"];
if (version == 1)
{
[self setRefusesFirstResponder: YES];
}
decode_NSInteger(aDecoder, &tmp);
_imageAlignment = tmp;
decode_NSInteger(aDecoder, &tmp);

View file

@ -0,0 +1,57 @@
#include "Testing.h"
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSValue.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSCell.h>
#include <AppKit/NSImageCell.h>
#include <AppKit/NSActionCell.h>
#include <AppKit/NSTextFieldCell.h>
#include <AppKit/NSButtonCell.h>
int main()
{
CREATE_AUTORELEASE_POOL(arp);
NSImageCell *imgCell;
NSActionCell *actCell;
NSButtonCell *buttCell;
NSTextFieldCell *tfCell;
NSCell *cell;
START_SET("NSCell RefusesResponder")
NS_DURING
{
[NSApplication sharedApplication];
}
NS_HANDLER
{
if ([[localException name] isEqualToString: NSInternalInconsistencyException ])
SKIP("It looks like GNUstep backend is not yet installed")
}
NS_ENDHANDLER
imgCell = [[NSImageCell alloc] initImageCell:nil];
pass([imgCell refusesFirstResponder] == YES, "NSImageCell initImageCell refusesFirstResponder");
cell = [[NSCell alloc] initImageCell:nil];
pass([cell refusesFirstResponder] == NO, "NSCell initImageCell refusesFirstResponder");
buttCell = [[NSButtonCell alloc] init];
pass([buttCell refusesFirstResponder] == NO, "NSButtonCell init refusesFirstResponder");
tfCell = [[NSTextFieldCell alloc] initTextCell:@""];
pass([tfCell refusesFirstResponder] == NO, "NSTextFieldCell initTextCell refusesFirstResponder");
actCell = [[NSActionCell alloc] init];
pass([actCell refusesFirstResponder] == NO, "NSActionCell init refusesFirstResponder");
cell = [[NSCell alloc] init];
pass([cell refusesFirstResponder] == NO, "NSCell init refusesFirstResponder");
END_SET("NSCell RefusesResponder")
DESTROY(arp);
return 0;
}