On Aug 10, 2004, at 6:44 PM, Sherm Pendley wrote:

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>

I figured that out.


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.


Except that it is the exact code used in ShuX2 and your example. It appears that the problem in that the window is a panel, not a window. The argument is there. It is an undef, just like in the example. It make be that the constructor before it is not getting built for whatever reason.

The problem I am encountering is not in the Perl code so much as what needs to be connected where in XCode and Interface Builder. Either I am missing a delegate link or some other set of links in the toolkit. The examples do not help in this case because you have to go back into the interface builder and try and guess what links are made where and what is relevant in the particular case.



Reply via email to