The problem in the headline is exactly what happens to me. One I select the desired file, the dialog of the open panel becomes unselectable, but holds above all other windows. Next I will explain:
Using the menu item in my application, I launch the configuration window this way:
-(void)launchConfigurationWindow { [self loadInfo]; [self makeKeyAndOrderFront:nil]; [NSApp runModalForWindow:self]; if (abortConfigurationOperation) return; [self saveInfo]; }
And this window can be closed with the "Finish" or "Cancel" button:
-(IBAction)finishButtonPressed:(id)sender { abortConfigurationOperation = false; [self orderOut:self]; [NSApp stopModal]; } -(IBAction)cancel:(id)sender { abortConfigurationOperation = true; [self orderOut:self]; [NSApp stopModal]; }
In this window, I have an "Advanced" button to display the "Advanced" window. Here is what I call it:
-(void)launchAdvancedWindow { [self loadAdvancedInfo]; [self makeKeyAndOrderFront:nil]; [NSApp runModalForWindow:self]; if (!abortAdvancedConfigurationOperation) { [self saveInfo]; } } -(IBAction)finishButtonPressed:(id)sender { abortAdvancedConfigurationOperation = false; [self orderOut:self]; [NSApp stopModal]; } -(IBAction)cancelButtonPressed:(id)sender { abortAdvancedConfigurationOperation = true; [self orderOut:self]; [NSApp stopModal]; }
And in the "Advanced" window, I have a button that calls NSOpenPanel to select a file and where the problem is:
-(IBAction)selectNewFile:(id)sender { NSOpenPanel* openDlg = [NSOpenPanel openPanel]; [openDlg setCanChooseFiles:YES]; [openDlg setTreatsFilePackagesAsDirectories:YES]; [openDlg setAllowsMultipleSelection:NO]; [openDlg setTitle:NSLocalizedString(@"Select file",nil)]; [openDlg setCanChooseDirectories:NO]; if ([openDlg runModal] == NSOKButton) { NSString* newFile = [(NSURL*)[[openDlg URLs] firstObject] path]; [self.filePathField setStringValue:newFile]; } }
As long as self.filePathField populated with newFile , the panel does not disappear; he just hangs there, primarily in other windows, is not amenable to selection. The only way to close this is to click the Cancel / Finish button in the Advanced window and the Cancel / Finish button in the Configuration window or close the application.
I believe this is due to the modals, but I have no idea how to solve it, and I donβt know the exact reason.
EDIT: I just need a solution for this problem, even if it means that you are not using modal files for the Configuration and Advanced windows, but I need something with an equivalent effect.
This means that: when my application is in focus and the Advanced window opens, it should be higher than other windows, and the main window of my application should be non-selectable; the same applies to the Configuration window when the Advanced window does not open. In addition, the NSOpenPanel dialog (which is called in the "Advanced" window) should work fine.
EDIT 2: Another detail: if you open the "Advanced" window, open another program, and then return to my application, the "Configuration" window keeps itself in front, holding the "Advanced" window.
EDIT 3: Another detail: If I close the Advanced window (Cancel or Finish button), the Advanced button will continue to search.