Browse Subversion Repository
Annotation of /XspfManager/NSControl_Validation.m
Parent Directory
| Revision Log
Revision 483 -
( hide annotations)
( download)
Fri Dec 31 05:16:20 2010 UTC
(13 years, 3 months ago)
by masakih
File size: 1450 byte(s)
[Merge] merge from branches/withBuildInPlayer@482
| 1 |
masakih |
479 |
// |
| 2 |
|
|
// NSControl_Validation.m |
| 3 |
|
|
// XspfManager |
| 4 |
|
|
// |
| 5 |
|
|
// Created by Hori,Masaki on 10/12/31. |
| 6 |
|
|
// Copyright 2010 masakih. All rights reserved. |
| 7 |
|
|
// |
| 8 |
|
|
|
| 9 |
|
|
#import "NSControl_Validation.h" |
| 10 |
|
|
|
| 11 |
|
|
|
| 12 |
|
|
@implementation NSObject (XspfMControlValidator) |
| 13 |
|
|
- (NSArray *)targetViews |
| 14 |
|
|
{ |
| 15 |
|
|
return [NSArray array]; |
| 16 |
|
|
} |
| 17 |
|
|
|
| 18 |
|
|
- (void)autoControlValidate |
| 19 |
|
|
{ |
| 20 |
|
|
NSArray *views = [self targetViews]; |
| 21 |
|
|
for(NSControl *control in views) { |
| 22 |
|
|
if(![control isKindOfClass:[NSControl class]]) continue; |
| 23 |
|
|
SEL action = [control action]; |
| 24 |
|
|
if(!action) continue; |
| 25 |
|
|
|
| 26 |
|
|
id target = [NSApp targetForAction:action to:[control target] from:control]; |
| 27 |
|
|
if(target && [target respondsToSelector:@selector(validateControl:)]) { |
| 28 |
|
|
[control setEnabled:[target validateControl:control]]; |
| 29 |
|
|
} |
| 30 |
|
|
if(!target || ![target respondsToSelector:action]) { |
| 31 |
|
|
[control setEnabled:NO]; |
| 32 |
|
|
} |
| 33 |
|
|
} |
| 34 |
|
|
} |
| 35 |
|
|
@end |
| 36 |
|
|
|
| 37 |
|
|
@implementation NSApplication (XspfMControlValidator) |
| 38 |
|
|
- (NSArray *)targetViews |
| 39 |
|
|
{ |
| 40 |
|
|
return [[[self mainWindow] contentView] subviews]; |
| 41 |
|
|
} |
| 42 |
|
|
@end |
| 43 |
|
|
@implementation NSWindow (XspfMControlValidator) |
| 44 |
|
|
- (NSArray *)targetViews |
| 45 |
|
|
{ |
| 46 |
|
|
return [[self contentView] subviews]; |
| 47 |
|
|
} |
| 48 |
|
|
@end |
| 49 |
|
|
@implementation NSView (XspfMControlValidator) |
| 50 |
|
|
- (NSArray *)targetViews |
| 51 |
|
|
{ |
| 52 |
|
|
return [self subviews]; |
| 53 |
|
|
} |
| 54 |
|
|
@end |
| 55 |
|
|
@implementation NSWindowController (XspfMControlValidator) |
| 56 |
|
|
- (NSArray *)targetViews |
| 57 |
|
|
{ |
| 58 |
|
|
return [[[self window] contentView] subviews]; |
| 59 |
|
|
} |
| 60 |
|
|
@end |
| 61 |
|
|
@implementation NSViewController (XspfMControlValidator) |
| 62 |
|
|
- (NSArray *)targetViews |
| 63 |
|
|
{ |
| 64 |
|
|
return [[self view] subviews]; |
| 65 |
|
|
} |
| 66 |
|
|
@end |
| 67 |
|
|
|
|