From 67eee29fdfad7c4d8fdf6aa2b7fa00a69bac0ce3 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Tue, 12 May 2020 14:11:48 +0200 Subject: [PATCH] Fixed regression that resulted in firstResponders not getting correctly updated on view changes --- MacPass/MPDocumentWindowController.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index 0eea00bd..ac9b4ff7 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -146,6 +146,14 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); - (void)setContentViewController:(NSViewController *)contentViewController { contentViewController.view.frame = self.window.contentView.frame; [super setContentViewController:contentViewController]; + if([contentViewController isKindOfClass:MPViewController.class]) { + /* enqueue async into main to catch some cases, where the UI would not set the responder correctly */ + MPDocumentWindowController * __weak welf = self; + dispatch_async(dispatch_get_main_queue(), ^{ + NSResponder *responder = ((MPViewController *)contentViewController).reconmendedFirstResponder; + [welf.window makeFirstResponder:responder]; + }); + } } #pragma mark MPDocument notifications