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 > A few questions (Cocoa)

A few questions (Cocoa)
Thread Tools
Fresh-Faced Recruit
Join Date: May 2002
Status: Offline
Reply With Quote
May 11, 2002, 03:28 PM
 
I'm just starting Cocoa programming, and I have a few problems:
1. How do I make it so that when the user closes the main window,the program quits?

2. How do put information on the about... and help... boxes?

3. I made a program that calculates a load of dot positions and uses NSBezierPath to draw a line. Is there something similar to draw disconnected dots?

Thanks for any help.
     
Forum Regular
Join Date: Oct 2001
Location: Sweden
Status: Offline
Reply With Quote
May 11, 2002, 06:24 PM
 
Originally posted by Khoth:
<STRONG>I'm just starting Cocoa programming, and I have a few problems:
1. How do I make it so that when the user closes the main window,the program quits?

2. How do put information on the about... and help... boxes?

3. I made a program that calculates a load of dot positions and uses NSBezierPath to draw a line. Is there something similar to draw disconnected dots?

Thanks for any help.</STRONG>
1. In your application delegate, put the following method:
- (BOOL)applicationShouldTerminateAfterLastWindowClo sedNSApplication *)theApplication
{
return YES;
}

2. For the about box, just include a Credits.rtf or Credits.html file in your application. You should get one for free from the project templates in ProjectBuilder, at least for NSDocument based apps.

/Tobias
     
Fresh-Faced Recruit
Join Date: May 2002
Status: Offline
Reply With Quote
May 11, 2002, 06:30 PM
 
1. How do I make it so that when the user closes the main window,the program quits?
Make an object that the window delegates to then add this method to it:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier> -(void)windowWillClose id)sender
{
[NSApp terminate:nil];
}
</font>[/code]
2. How do put information on the about... and help... boxes?
The "About" info is in a file called InfoPList.strings in your project. Help is more complicated. not sure how to do it but my buddy does. I'll ask him if no one else offers help.
3. I made a program that calculates a load of dot positions and uses NSBezierPath to draw a line. Is there something similar to draw disconnected dots?
I like tacos.
Love,
The Surfer
     
Fresh-Faced Recruit
Join Date: May 2002
Status: Offline
Reply With Quote
May 12, 2002, 12:45 AM
 
BTW, the Quit method posted by tobli will quit your app after the _last_ window closes, whereas the method I posted quits when the window you delegated to the controller closes, regardless of what other windows are open at the time. (Unless they have unsaved changes, or something.)
Love,
The Surfer
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
May 14, 2002, 02:37 AM
 
3) NSBezierPath should work here as well -- use the moveToPoint: method to move the current point around without drawing lines. To draw a point, uh, I guess you could just call lineToPoint: on the same point, and hope the line width is enough to draw the point. That, or draw a (small) circle.
     
Khoth  (op)
Fresh-Faced Recruit
Join Date: May 2002
Status: Offline
Reply With Quote
May 14, 2002, 12:31 PM
 
Thanks, people.

lineToPoint to the same place doesn't seem to work. I'll try circles, but they seem overkill somehow.
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:58 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2