Open panel is permanently dead?
Open panel is permanently dead?
- Subject: Open panel is permanently dead?
- From: Tom Davie <email@hidden>
- Date: Fri, 19 Feb 2010 14:17:58 +0000
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:
- (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@hidden)
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:
This email sent to email@hidden