Posted By

buscarini on 11/30/-1


Tagged

textmate cocoa mac panel abrir openfile


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

daniel
xaviaracil


Panel para abrir ficheros


 / Published in: Objective C
 

  1. - (IBAction)chooseWhere:(id)sender
  2. {
  3.  
  4. NSLog(@\"Choosing where\");
  5.  
  6. // TODO: remove the item
  7.  
  8. NSOpenPanel *panel = [[NSOpenPanel alloc] init];
  9.  
  10. [panel setCanChooseDirectories:YES];
  11. [panel setCanCreateDirectories:YES]; // Added by DustinVoss
  12. [panel setPrompt:@\"Choose folder\"]; // Should be localized
  13. [panel setCanChooseFiles:NO];
  14.  
  15. destinationFolder = [[NSString alloc] init];
  16.  
  17. [panel beginSheetForDirectory:nil file:destinationFolder
  18. types:nil modalForWindow:mainWindow
  19. modalDelegate:self didEndSelector:@selector(openPanelDidEnd:
  20. returnCode:
  21. contextInfo:)
  22. contextInfo:nil];
  23.  
  24. }
  25.  
  26.  
  27.  
  28. - (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo{
  29.  
  30.  
  31. if (returnCode==NSOKButton){
  32. destinationFolder = [sheet filename];
  33. [destinationTextField setStringValue:destinationFolder];
  34. NSLog(@\"OK button pressed\");
  35. }
  36.  
  37. if (returnCode==NSCancelButton){
  38. NSLog(@\"Cancel button pressed\");
  39. }
  40.  
  41.  
  42. // stringByAppendingString:@\"Open panel ended\"];
  43.  
  44. NSLog(destinationFolder);
  45.  
  46. }

Report this snippet  

You need to login to post a comment.