Cocoa Buttons Linked To Windows

qbkd10

Registered
I am creating a very basic application for the Mac in Cocoa, and I am trying to link an NSButton instance to open a window. How would I go about this in IB3?
 
I'm still using IB2, but I assume the procedure is the same in IB3:

Hold down the control key, and drag from the button to the window's icon in the "instances" tab of the main nib window. You'll see a list of actions appear in the Inspector palette. Connect it to "makeKeyAndOrderFront:". That should do it.
 
Nah, that's not helping, it won't let me make a connection between the button and the window's instance. Any other ideas?
 
Hmm. Maybe the button is already connected to something else, in which case it wouldn't allow new connections (it would instead bring up the outlets panel). You could try with a new button, or select the existing button and double-check that it's not connected to anything by going to the Inspector's "Connections" section and selecting the Target/Action tab.
 
Make sure you select the button first. The attached nib file has a window with a button, when you click the button another window will display or come to the front. For some reason when I test the interface the second window is always visible. I _though_ that was controlled by 'Visible at launch' controlled but it doesn't seem to work quite as I expected. Run it using the Simulate Interface option under File in Interface Builder.
 

Attachments

  • ButtonTest.xib.zip
    22.8 KB · Views: 0
Wait, just another question, how would you go about doing this with AppleScripts as opposed to opening windows?

EDIT: Never mind. I'll just post a new thread.
 
Back
Top