Re: [Q] SavePanel NSFileHandlingPanelCancelButton
Re: [Q] SavePanel NSFileHandlingPanelCancelButton
- Subject: Re: [Q] SavePanel NSFileHandlingPanelCancelButton
- From: Andy Lee <email@hidden>
- Date: Sun, 16 Jun 2002 12:30:55 -0400
At 12:14 PM -0400 6/16/02, Andy Lee wrote:
Disclaimer: I haven't compiled any of the above.
Okay, FWIW I quickly tried my code and it found the Cancel button
successfully (and the Save button when I tried that). Feel free to
use if this helps or ignore if not:
-----NSView_Utils.h-----
#import <Cocoa/Cocoa.h>
@interface NSView (Utils)
- (id)viewOfClass:(Class)aClass withTag:(int)tag;
- (id)buttonWithTag:(int)tag;
@end
-----end NSView_Utils.h-----
-----NSView_Utils.m-----
#import "NSView_Utils.h"
@implementation NSView (Utils)
- (id)viewOfClass:(Class)aClass withTag:(int)tag
{
NSEnumerator* e;
NSView* aSubview;
NSView* result;
if (([self tag] == tag) && [self isKindOfClass:aClass])
return self;
e = [[self subviews] objectEnumerator];
while ((aSubview = [e nextObject]))
if ((result = [aSubview viewOfClass:aClass withTag:tag]))
return result;
return nil;
}
- (id)buttonWithTag:(int)tag
{
return [self viewOfClass:[NSButton class] withTag:tag];
}
@end
-----end NSView_Utils.m-----
-----test code-----
NSSavePanel *panel = [NSSavePanel savePanel];
NSButton* cancelButton =
[[panel contentView] buttonWithTag:NSFileHandlingPanelCancelButton];
NSLog([cancelButton title]);
-----end test code-----
--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.