• 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: multiple windowcontrollers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multiple windowcontrollers


  • Subject: Re: multiple windowcontrollers
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Thu, 24 Jun 2004 14:18:19 -0700

Hello...

Well, if you want one info window per document, then you would want the document to have multiple window controllers. I misunderstood what you were trying to do, since I thought your second question was asking how to keep a single info updated with the information for whichever document was in front.


If you want to use a menu item to display the info window that belongs to the active document, then you should probably put the action for the menu item in your document class.

To make the connections for the menu in IB (since you can't make a connection directly to a document in the main nib) you make the connection to the "First Responder" object alias in the main nib file instead. This causes the action to be sent down the responder chain whenever the menu item is selected, and it will trigger the action in the active document which can display the info window (or create the controller if needed and display the window) for that document. That way the info window shown will always be the one from the active document and you don't have to deal with forwarding the message through your main controller.

Since the "First Responder" probably won't have an action that matches the method you want to use, you need to add it to the list of actions. You can do this by selecting the "First Responder", switching to the "Classes" tab in the nib window, and adding an action with the correct name in the inspector pallete.


Hope that helps,

Louis


On Jun 24, 2004, at 3:23 AM, Louis C. Sacha wrote:

Hello...

It sounds like you really don't want to have each document use more than one window controller...

Since you seem to want one info window per application as opposed to one per document, the info window controller (and the search window controller if/when you implement it) should really belong to the main application controller.

Actually, the infowindow should be one per document, so I can compare them on the screen. I thought about a sheet, but then the main window becomes uneditable. Was my initial suggestion correct in that case to use more than one windowcontroller?

In regard to making sure that the info window always displays information about the current (frontmost) document when there are multiple documents open, NSDocumentController provides the currentDocument method which will return the NSDocument instance associated with the main window.

You could register as an observer for the NSWindowDidBecomeMainNotification sent out when the main window changes, and refresh your info window if the document has changed.

Thanks, those are very useful tips.


- Koen.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: multiple windowcontrollers
      • From: Koen van der Drift <email@hidden>
References: 
 >multiple windowcontrollers (From: Koen van der Drift <email@hidden>)
 >Re: multiple windowcontrollers (From: "Louis C. Sacha" <email@hidden>)
 >Re: multiple windowcontrollers (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Passing by reference
  • Next by Date: memory leaks
  • Previous by thread: Re: multiple windowcontrollers
  • Next by thread: Re: multiple windowcontrollers
  • Index(es):
    • Date
    • Thread