On 18/12/2009 Graham Cox wrote:

There is an easy solution - do it in your window controller.

Could you please extend this anwer? I have two window controllers - the main window (AppController) where I have a button, opening a popup panel, and this popup panel controller. What controller do you have in mind? Should I do all my calls and perform checks from the main window?

My popup panel reflects a progress of some external process. I've created a test project, where this "popup" panel with the progress indicator is the main window. And now I'd like to transfer all the code, as it is, from this test project into the real project. In test project I had "Start" button, which launched an external process. In the real project I have similar button in the main window. So should I add the launching code to this button click handler? Is this your advice? My idea was to do it "asynchronously", as popup window will appear on screen, in order do not create any "hang-up" on the button click. What you think about this?

Another and even more interesting question is how to process the external process termination correctly. In my test project I had "Cancel" button, which calls NSTask terminate message, and task termination was processed by notification receiver. In particular this code called window close method. This was the end of my test project. But I have another situation in in my real project. I'd like to show an alert box after popup panel closure. How to intercept the window closure event? I have no idea.

Best regards,
Alexander

----- Original Message ----- From: "Graham Cox" <graham....@bigpond.com>
To: "Alexander Bokovikov" <openwo...@uralweb.ru>
Cc: <cocoa-dev@lists.apple.com>
Sent: Friday, December 18, 2009 6:13 PM
Subject: Re: NSWindow delegate messages question



On 18/12/2009, at 10:12 PM, Alexander Bokovikov wrote:

I'd like to launch some process (no matter what exactly, it will work in different thread) as soon this popup panel will appear on screen. Of course, I could launch this process from within the same click handler above, but I believe it will be better to do it all in the WindowController's module, related to the popup panel. My question is: what window delegate message should I use? Will it be OK to use windowDidBecomeKey message or should I use windowDidExposed? Or whatever else?

Another question is what notification could I use to display an alert box, appearing _after_ this popup window will disappear from screen? For example, I have a "Cancel" button on this popup panel, which should terminate the launched process and (as a result of NSTask termination notification) panel should be closed. For the sake of simplicity let's imagin, we're closing the panel by button directly:

- (IBAction) btnCancelClick:(id)sender {
[[self window] close];
}

My question is: what window delegate message should I use to show an NSAlert, in order my alert box would appear on screen already _after_ hiding of the popup panel? As far as I can see, there is no windowDidClosed message, but there is only windowWillClose. Is there any easy solution here?


There is an easy solution - do it in your window controller. Since it is responsible for opening and closing the windows, it knows when to cause these other events as well. I wouldn't use window activation or key notifications since that relates purely to its appearance which likely as not has nothing to do with your logic as such - the window coming up and going away are further effects of this logic, not its causes.

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to