• 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: "Modal Session Requires Modal Window" Error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Modal Session Requires Modal Window" Error


  • Subject: Re: "Modal Session Requires Modal Window" Error
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Mon, 21 Jun 2004 16:18:15 -0700

Hello...

Most of the time, the toolbar item doesn't contain the code to do anything, it acts in a similar way to a menu item and when it is selected it passes the action to the responder chain.

The way this is normally implemented is that the toolbar item has an action, but the target is set to nil. When a toolbar item has a nil target, the action is sent to whichever object in the responder chain is the first to implement the action method.

An example is the default Apple "Print" toolbar item, which will send the printDocument: action down the responder chain.

Instead of implementing the action in your toolbar item or toolbar delegate, you would implement the action method in your document, etc, the same way you would implement the actions for menu items.


If you prefer to implement your toolbar items differently, you can also potentially get the active window using the NSApplication mainWindow or keyWindow methods. In a document based app, you can use the NSDocumentController currentDocument method to get the document associated with the main window.

If you need to do some sort of processing in your toolbar item before sending the action down the responder chain, you can use the NSApplication sendAction:to:from: method with nil as the to: argument in order to send out the action to the responder chain after you've done whatever you need to do.


Hope that helps,

Louis


I have two random questions about Cocoa development.
...
Also, I was also wondering if there's a way to get which window contains a toolbar item that was clicked, since it sends the toolbar item as the sender to the method that responds to the click. I've got a bunch of different windows that have the same toolbar, and there doesn't seem to be a way to differentiate between a toolbar button click in one window from another, given that they're all synchronized since they use the same toolbar identifier. I've looked through the methods implemented by NSToolbarItem and NSToolbar, but none of them seem to be able to give me the window that contains the toolbar or toolbar item.

Any help would be much appreciated. Thanks.

-- Simone Manganelli
_______________________________________________
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.


References: 
 >"Modal Session Requires Modal Window" Error (From: Simone Manganelli <email@hidden>)

  • Prev by Date: Re: Value Transformers and MVC ...
  • Next by Date: Cmd+ to be same as cmd=
  • Previous by thread: "Modal Session Requires Modal Window" Error
  • Next by thread: NSTableView subclass and setDoubleAction
  • Index(es):
    • Date
    • Thread