On Mar 14, 2008, at 5:16 PM, Hans van der Meer wrote:

I thought to implement an open panel on my main window and expected it to wait for the dismissal of the sheet. It seems that actually the events are out of the inendedorder. What is wrong with the following code? Why didn't it wait for the sheet being closed?

// Put up the sheet for and retrieve the return value.
        [panel beginSheetForDirectory:nil
                file:nil
                types:nil
                modalForWindow:aWindow
                modalDelegate:self
                
didEndSelector:@selector(openSheetDidEnd:returnCode:contextInfo:)
                contextInfo:nil];
        
// If we have a file path the data will be read.
        NSLog(@"directly after beginSheetForDirectory");
                
        .....

- (void) openSheetDidEnd:(NSOpenPanel *)panel
                returnCode:(int)returnCode contextInfo:(void *)contextInfo; {
        NSLog(@"directly inside openSheetDidEnd");
        if (NSOKButton == returnCode)           
                NSLog(@"chosen sheet %@", [[panel filenames] objectAtIndex:0]);
        else
                NSLog(@"sheet cancelled");
}

This line:

NSString *filePath = [[panel filenames] objectAtIndex:0];

should be in the openSheetDidEnd:(NSOpenPanel *)panel... method.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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]

Reply via email to