/ Published in: Objective C
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
- (IBAction)chooseWhere:(id)sender { NSLog(@\"Choosing where\"); // TODO: remove the item NSOpenPanel *panel = [[NSOpenPanel alloc] init]; [panel setCanChooseDirectories:YES]; [panel setCanCreateDirectories:YES]; // Added by DustinVoss [panel setPrompt:@\"Choose folder\"]; // Should be localized [panel setCanChooseFiles:NO]; destinationFolder = [[NSString alloc] init]; [panel beginSheetForDirectory:nil file:destinationFolder types:nil modalForWindow:mainWindow modalDelegate:self didEndSelector:@selector(openPanelDidEnd: returnCode: contextInfo:) contextInfo:nil]; } - (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo{ if (returnCode==NSOKButton){ destinationFolder = [sheet filename]; [destinationTextField setStringValue:destinationFolder]; NSLog(@\"OK button pressed\"); } if (returnCode==NSCancelButton){ NSLog(@\"Cancel button pressed\"); } // stringByAppendingString:@\"Open panel ended\"]; NSLog(destinationFolder); }