(OSX) Handle window sheets better

This commit is contained in:
meancoot 2013-07-07 20:46:46 -04:00
parent a09f28c319
commit 1b0e86f5af

View File

@ -550,27 +550,32 @@ int main(int argc, char *argv[])
NSOpenPanel* panel = [NSOpenPanel openPanel]; NSOpenPanel* panel = [NSOpenPanel openPanel];
[panel beginSheetModalForWindow:window completionHandler:^(NSInteger result) [panel beginSheetModalForWindow:window completionHandler:^(NSInteger result)
{ {
[NSApplication.sharedApplication stopModal];
if (result == NSOKButton && panel.URL) if (result == NSOKButton && panel.URL)
{ {
_file = panel.URL.path; _file = panel.URL.path;
[self chooseCore]; [self performSelector:@selector(chooseCore) withObject:nil afterDelay:.5f];
} }
}]; }];
[NSApplication.sharedApplication runModalForWindow:panel];
} }
- (void)chooseCore - (void)chooseCore
{ {
[NSApplication.sharedApplication beginSheet:_coreSelectSheet modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil]; [NSApplication.sharedApplication beginSheet:_coreSelectSheet modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil];
[NSApplication.sharedApplication runModalForWindow:_coreSelectSheet];
} }
- (IBAction)coreWasChosen:(id)sender - (IBAction)coreWasChosen:(id)sender
{ {
[NSApplication.sharedApplication stopModal];
[NSApplication.sharedApplication endSheet:_coreSelectSheet returnCode:0];
[_coreSelectSheet orderOut:self];
NSComboBox* cb = (NSComboBox*)[_coreSelectSheet.contentView viewWithTag:1]; NSComboBox* cb = (NSComboBox*)[_coreSelectSheet.contentView viewWithTag:1];
RAModuleInfo* module = (RAModuleInfo*)cb.objectValueOfSelectedItem; RAModuleInfo* module = (RAModuleInfo*)cb.objectValueOfSelectedItem;
apple_run_core(module, _file.UTF8String); apple_run_core(module, _file.UTF8String);
[NSApplication.sharedApplication endSheet:_coreSelectSheet returnCode:0];
[_coreSelectSheet orderOut:self];
} }
#pragma mark RetroArch_Platform #pragma mark RetroArch_Platform