Re: Open document panel always on top - Mountain Lion
Re: Open document panel always on top - Mountain Lion
- Subject: Re: Open document panel always on top - Mountain Lion
- From: Matthew LeRoy <email@hidden>
- Date: Wed, 15 Oct 2014 14:30:45 +0000
- Thread-topic: Open document panel always on top - Mountain Lion
On 10/10/14, 8:29 PM, "Quincey Morris" <email@hidden<mailto:email@hidden>> wrote:
On Oct 10, 2014, at 13:34 , Matthew LeRoy <email@hidden<mailto:email@hidden>> wrote:
Not entirely sure where to go from here.
It’s not clear to me whether the deferral of the open panel’s disappearance is a mere implementation detail of NSDocumentController, or if it’s a consequence of what you chose to do in your completion handler.
I think I’d be inclined to sacrifice a bit of time to experiment with handling the open panel yourself, in advance of diving into NSDocumentController, at least for the handling of passwords. That is, provide your own action method in place of ‘openDocument:’ for the relevant menu item. Then you can ‘orderOut:’ the open panel exactly when you want, and any duplication of effort may be less (in terms of development time and pain) then “customizing” the behavior of NSDocumentController.
Just wanted to follow up on this and relay my “solution” for posterity.
Before starting this thread, I was already providing my own custom action method in place of ‘openDocument:' as you suggested, but for a different reason: I needed to customize the way that a certain type of document (call it Type A, different from the document type with the password, call it Type B) was opened. My custom action method just called [self beginOpenPanelWithCompletionHandler:], passing a custom completion handler. In the completion handler, I looped over the URLs and checked the document type for each one. If it was Type A I did my custom opening logic; for every other type I called [self openDocumentWithContentsOfURL:…].
After moving my password-checking logic out of -[NSDocument readFromURL:…] and into an override of -[NSDocumentController openDocumentWithContentsOfURL:…], I started having the problem of the Open panel staying up and obscuring the password dialog on both 10.8 and 10.9 — a regression, as I was only having the problem on 10.8 originally. Out of curiosity, I tried removing my custom action method and instead just using openDocument:, and lo and behold the problem went away on both 10.8 and 10.9. Only problem was that I lost my custom opening logic for Type A documents because it was implemented in the custom completion handler passed to ‘beginOpenPanelWithCompletionHandler:’, inside my custom action method.
But then it occurred to me that a better place to implement the custom logic for Type A documents was inside the override of -[NSDocumentController openDocumentWithContentsOfURL:…], where I was now providing the password-checking logic for Type B. So, I re-implemented the Type A opening logic there, got rid of my custom action method and used openDocument: instead, and now everything is working.
So the bottom line is that for whatever reason, calling -[NSDocument beginOpenPanelWithCompletionHandler:] and passing my own completion handler, rather than just using openDocument:, caused the Open panel to not order out early enough in the process.
Many thanks for the suggestions and guidance as I worked through this!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden