On Feb 19, 2010, at 6:17 AM, Tom Davie wrote:
> Hi,
>
> I'm having some problems with an open panel. I display the panel, allow the
> user to chose and image, and then do some work, which involves showing a
> sheet while the work is done. This all works wonderfully, until the user
> clicks the "set texture" button again, and my method is called again. The
> second time, for some reason, the open panel is never displayed.
>
> Can anyone tell what's going on here? I've added code below:
SWAG here: check the value of isReleasedWhenClosed. If it's YES, that
would explain the panel
being dead after the first time.
Consider using orderOut to dismiss the panel instead of close.
Cheers,
. . . . . . . . Henry
>
> - (IBAction)setTexture:(id)sender{
> NSOpenPanel
> <http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSOpenPanel.html>
> *panel = [NSOpenPanel
> <http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSOpenPanel.html>
> openPanel];
>
> [panel setCanChooseFiles:YES];
> [panel setCanChooseDirectories:NO];
> [panel setResolvesAliases:YES];
> [panel setAllowsMultipleSelection:NO];
> [panel setTitle:@"Select Texture"];
> [panel setAllowedFileTypes:[NSArray
> <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html>
> arrayWithObject:@"png"]];
> [panel beginSheetModalForWindow:[delegate windowForSheet]
> completionHandler:^(NSInteger result)
> {
> if (result == NSFileHandlingPanelOKButton)
> {
> NSURL
> <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSURL.html>
> *selection = [[panel URLs] objectAtIndex:0];
> NSImage
> <http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSImage.html>
> *image = [[[NSImage
> <http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSImage.html>
> alloc] initWithContentsOfURL:selection] autorelease];
>
> [self.item addObserver:self
> forKeyPath:@"textureIsCompressed"
> options:NSKeyValueObservingOptionNew context:nil];
> self.item.texture = image;
>
> [panel close];
>
> [NSApp beginSheet:compressingTexturePanel
> modalForWindow:[delegate windowForSheet]
> modalDelegate:self
>
> didEndSelector:@selector(compressionSheetDidEnd:)
> contextInfo:nil];
> [compressingProgress startAnimation:self];
> }
> }];}
>
> Thanks
>
> Tom Davie
> _______________________________________________
>
> Cocoa-dev mailing list ([email protected])
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/appledeveloper%40trilithon.com
>
> This email sent to [email protected]
=================================================
iPhone App Development and Developer Education . . .
Visit www.nonatomic-retain.com
Mac OSX Application Development, Plus a Great Deal More . . .
Visit www.trilithon.com
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]