Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Menu item action to controller object

Menu item action to controller object
Thread Tools
xoedusk
Fresh-Faced Recruit
Join Date: Sep 2006
Status: Offline
Reply With Quote
Sep 3, 2006, 10:20 PM
 
I am using Cocoa.

I'm trying to make one of my menu items perform an instance method (I think those are the right words) of my controller object. When I connect from the menu item to the controller object, there are only a few options availble for connection, such as fax, performClick, print, takeDoubleValueFrom, etc.

So to get around that I have a hidden button on my window, which the menu item performClicks on, and that button is in turn connected to the controller object.

Is there a better way to do this?
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Sep 3, 2006, 10:26 PM
 
Add more methods to your controller object in Interface Builder?
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Gametes
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status: Offline
Reply With Quote
Sep 4, 2006, 11:53 AM
 
You should read this: Currency Converter tutorial Seriously, it'll take a few hours but it will save you days of heartache. It, and pretty much every tutorial I've ever seen, is well worth the investment of understanding them. By the way, the best Ladder of tutorials ever for Cocoa, even though they're like 5 years old, is Oreilly's MacDevCenter. Start at the bottom, more or less. More up to date and really helpful gab is at CocoaDevCentral

But basically, you need to implement a method in your class called (and it must appear in the header file too):

-(IBAction)doSomething: (id)sender;
then, in IB, go to the menu "Classes - > Read myClass.h". Now dragging a connection from your menu item to that object instance should show you the option of connecting it to that method.
you are not your signature
     
xoedusk  (op)
Fresh-Faced Recruit
Join Date: Sep 2006
Status: Offline
Reply With Quote
Sep 4, 2006, 04:21 PM
 
Thank you both very much for helping out a newb!
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:01 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,