[Resolved] NSOpenPanel Problem - MacRumors Forums
Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 17, 2012, 05:03 PM   #1
larswik
macrumors 65816
 
Join Date: Sep 2006
NSOpenPanel Problem

When I open an NSOpenPanel to get a file and click OK It is not responding to the OK button the first time? If seems to disappear then reappear with an empty folder. This causes me to have to back out of the folder and go back into it to select the item again. After that it loads just fine? I have googled a looked at other examples and mine seems no different? I made a demo video to better demonstrate the issue here

http://sbtraveler.tv/odd/NSOpenPanel.mov

Code:
- (IBAction)importItem:(id)sender{
    NSOpenPanel *openDlg = [NSOpenPanel openPanel];;

    NSString *pathName = @"/Users/larspro/Documents/ERad files/items database";
    [openDlg setDirectoryURL:[NSURL URLWithString:pathName]];
    [openDlg setCanChooseFiles:YES];
    [openDlg setCanChooseDirectories:NO];
    [openDlg runModal];
    NSInteger result = [openDlg runModal];
    
    if (result == NSFileHandlingPanelCancelButton) {
        [openDlg orderOut:self];
    }

     if ( result == NSOKButton) {
         if (counter == 0) {
             item1Array = [[NSMutableArray alloc] initWithContentsOfURL:openDlg.URL];
             NSImage *importImage = [[NSImage alloc] initWithData:[item1Array objectAtIndex:0]];
             
             item1ImageView.image = importImage;
             firstName.stringValue = [item1Array objectAtIndex:1];
             [openDlg orderOut:self];
             
         }
         if (counter == 1) {
             item2Array = [[NSMutableArray alloc] initWithContentsOfURL:openDlg.URL];
             NSImage *importImage = [[NSImage alloc] initWithData:[item2Array objectAtIndex:0]];
             item2ImageView.image = importImage;
             secondName.stringValue = [item2Array objectAtIndex:1];
             [openDlg orderOut:self];
         }
         if (counter == 2) {
             item3Array = [[NSMutableArray alloc] initWithContentsOfURL:openDlg.URL];
             NSImage *importImage = [[NSImage alloc] initWithData:[item3Array objectAtIndex:0]];
             item3ImageView.image = importImage;
             thirdName.stringValue = [item3Array objectAtIndex:1];
             [openDlg orderOut:self];
         }
         if (counter == 3) {
             item4Array = [[NSMutableArray alloc] initWithContentsOfURL:openDlg.URL];
             NSImage *importImage = [[NSImage alloc] initWithData:[item4Array objectAtIndex:0]];
             item4ImageView.image = importImage;
             forthName.stringValue = [item4Array objectAtIndex:1];
             [openDlg orderOut:self];
         }
         counter++;

     }

}
__________________
I know more than yesterday.
Lars

Last edited by larswik; Dec 17, 2012 at 10:25 PM.
larswik is online now   0 Reply With Quote
Old Dec 17, 2012, 10:25 PM   #2
larswik
Thread Starter
macrumors 65816
 
Join Date: Sep 2006
Discovered the problem. I did not need the code [openDlg runModal]. It seems that just the NSOpenPanel *openDlg = [NSOpenPanel openPanel]; presents the modalWindow, this caused the redundant opening of the windows.
__________________
I know more than yesterday.
Lars
larswik is online now   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iTunes DRM problem? Or, HD Versions of Movie on ATV1 Problem? Aqueous Apple TV and Home Theater 5 Feb 9, 2014 07:54 AM
iPhone: Gmail App problem or Jailbreak Problem? ARSkemp Jailbreaks and iOS Hacks 6 Apr 9, 2013 11:43 PM
MacBook Pro Problem! Booting up problem! Legolasas MacBook Pro 2 Jan 21, 2013 09:54 AM
Help, unexplainable problem (for me) [Intermittent slowdown problem] LittleBig MacBook Pro 5 Nov 5, 2012 05:29 PM

Forum Jump

All times are GMT -5. The time now is 04:39 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC