• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSWindow delegate messages question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindow delegate messages question


  • Subject: Re: NSWindow delegate messages question
  • From: "Alexander Bokovikov" <email@hidden>
  • Date: Fri, 18 Dec 2009 20:28:21 +0500

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" <email@hidden>
To: "Alexander Bokovikov" <email@hidden>
Cc: <email@hidden>
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 (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


References: 
 >NSWindow delegate messages question (From: "Alexander Bokovikov" <email@hidden>)
 >Re: NSWindow delegate messages question (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Enabling menu items...
  • Next by Date: Thread safe QT playback
  • Previous by thread: Re: NSWindow delegate messages question
  • Next by thread: Intercepting events and touches in UIPickerView subclasses? (or, WTF is going in the UIPickerView's responder chain?)
  • Index(es):
    • Date
    • Thread