implement suggestion to call validation methods in perform methods.

This commit is contained in:
Gregory John Casamento 2020-08-14 11:13:45 -04:00
parent 41484fd5b3
commit 0740fc5f14
2 changed files with 18 additions and 3 deletions

View file

@ -41,6 +41,7 @@
@protocol NSUserInterfaceValidations
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
@end
#endif // _GNUstep_H_NSUserInterfaceValidation

View file

@ -27,6 +27,7 @@
#import "AppKit/NSTextFinder.h"
#import "AppKit/NSTextView.h"
#import "AppKit/NSUserInterfaceValidation.h"
#import "GSTextFinder.h"
@ -114,15 +115,23 @@
// Validating and performing
- (void) performTextFinderAction: (id)sender
{
if (_finder == nil)
BOOL valid = [self validateUserInterfaceAction: sender];
if (valid)
{
_finder = [[GSTextFinder alloc] init];
if (_finder == nil)
{
_finder = [[GSTextFinder alloc] init];
}
}
}
- (void) performFindPanelAction: (id)sender
{
[self performAction: [sender tag]];
BOOL valid = [self validateUserInterfaceAction: sender];
if (valid)
{
[self performAction: [sender tag]];
}
}
- (void) performAction: (NSTextFinderAction)op
@ -174,6 +183,11 @@
}
}
- (BOOL) validateUserInterfaceAction: (id<NSValidatedUserInterfaceItem>)item
{
return YES;
}
- (BOOL) validateAction: (NSTextFinderAction)op
{
return YES;