On Aug 10, 2004, at 6:56 PM, Alan Olsen wrote:

Well, I figured out why I was getting the disconnect message... Connecting to first responder instead of file's owner helps...

Sorry, I misunderstood the question - I was describing how you create a window by loading a Nib, and connect button clicks and other events generated from within that window to its owner.


As you've found, menu events are different, as they're not connected to a particular window instance; generally, you want to send them to whatever instance is currently active, or failing that, to the application controller. So instead of making a hard connection to a single object, the first responder sends a message to the first object in the "responder chain" that implements the necessary method. So, you don't have to worry about which window is currently the main window - Cocoa automatically ensures that the main window is at the top of the responder chain.

For more about the responder chain and handling menu events, see the "Getting Started" tutorial:

<http://camelbones.sourceforge.net/getstarted/index.php>

2004-08-10 15:42:53.600 PerlButtonTest[1001] Perl error: Can't call method "makeKeyAndOrderFront" on an undefined value at /Users/alan/Documents/XCode projects/PerlButtonTest.app/Contents/Resources/PerlButtonTest.pm line 45.

The method name here is significant - the name of the method is 'makeKeyAndOrderFront:'. Note the trailing colon - it's important, and signifies that the method requires a single argument. The lack of that colon in the error message shows the required argument is missing.


sherm--



Reply via email to