 |
 |
A few questions (Cocoa)
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2002
Status:
Offline
|
|
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
|
|
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 sed  NSApplication *)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
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2002
Status:
Offline
|
|
Thanks, people.
lineToPoint to the same place doesn't seem to work. I'll try circles, but they seem overkill somehow.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|