Re: [Q] SavePanel NSFileHandlingPanelCancelButton
Re: [Q] SavePanel NSFileHandlingPanelCancelButton
- Subject: Re: [Q] SavePanel NSFileHandlingPanelCancelButton
- From: Matt Neuburg <email@hidden>
- Date: Sun, 16 Jun 2002 08:06:34 -0700
>
From: Mark de Jong <email@hidden>
>
I'm trying to change the title of the cancel button in the NSSavePanel.
>
According to the documentation, I should be able to use the constant
>
"NSFileHandlingPanelCancelButton" to get at the NSButton.
>
>
From what I understand, the following code should work:
>
cancelButton = [[panel contentView]
>
viewWithTag:NSFileHandlingPanelCancelButton];
>
[cancelButton setTitle:@"Quit"];
Interesting assumption. I don't see anything in the docs that associates
the NS... constants for NSSavePanel with the *tags* for objects in the
panel.
>
So, the question is: how do I correctly change the title of the cancel
>
button?
Maybe this is isn't "correctly" but it works for me:
- (id) seekCancelButton: (NSView*) aView {
NSEnumerator* e;
NSView* aSubview;
NSView* result;
if ([aView isKindOfClass: [NSButton class]] &&
[[(NSButton*)aView title] isEqualToString: @"Cancel"])
return aView;
e = [[aView subviews] objectEnumerator];
while ((aSubview = [e nextObject]))
if ((result = [self seekCancelButton: aSubview]))
return result;
return nil;
}
Use it like this:
NSSavePanel *panel = [NSSavePanel savePanel];
NSButton* cancelButton =
[self seekCancelButton: [panel contentView]];
[cancelButton setTitle: @"Quit"];
[panel runModal];
m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
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.