You need to log in to create posts and topics.
FBCocoa
1,678 Posts
#1 · January 5, 2011, 11:42 am
Quote from Forum Archives on January 5, 2011, 11:42 amPosted by: svanvoorst <svanvoorst@...>
It appears that we now have a way to use FB to create Cocoa windows that use Cocoa events. I have done this once, but need others to reproduce the findings. For those willing, please try the following:You will need 3 items: 1) Cocoa.xib created with IB, 2) Info.plst with 2 fields "Main nib file base name" and Principal Class ( you can use a copy from the FBCocoa folder recently cited by rp on the FB list, just change the file base name to match what you have created) and 3) a FB file which I am posting below.1) Create a cocoa .xib using IB with the Cocoa application template. There is already a window included, so just drag a push button to it and name the button "Beep". Also drag an NSObjectController to the window and rename it myController using the inspector. We are going to manually set the outlet and action using the library palette. Find "myController" in the list of objects and with "Classes" selected at the top of the window go to the bottom of the window and click on "Outlets". Hit the "+" button to add your own outlet. Type in "beepBtn" and set the Type field to "NSButton". Then select the "Actions" button and type in "soundOff" and leave the Type as "id". Save everything. Then go back to your window and Ctrl-Drag from the Controller to the "Beep" push button. When you do this you should see the "beepBtn"outlet which you just entered - go ahead and select this. Then reverse Ctrl-Drag from the "Beep" button back to "myController" and you should see the action "soundOff" - go ahead and select it as well. At this point everything should be hooked up. XCode is case sensitive so make sure you have no typos.2) Make sure you have your info.plst with the file base name field correctly filled out. It should be the same as the name for your .xib3) Copy this code into FB and compile with the Objective C. You should hear a beep when you push the button. Note that there is no RunApplicationEventLoop() in this code and the window is a cocoa window.'---------------/*Written by S. Van Voorst {20110105}*/include resources "myFBCocoa.xib"toolbox fn NSApplicationMain( SInt32, ptr ) = SInt32BeginCDeclaration@interface myController : NSObjectController{IBOutlet NSButton *beepBtn;}-(IBAction) soundOff:(id)sender;@end //interfaceEndCBeginCFunction@implementation myController-(IBAction) soundOff:(id)sender{NSBeep();}@end //implementationEndCBeginCCode{NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];NSObjectController *myController = [[NSObjectController alloc]init];[myController release];[pool drain];return NSApplicationMain(argc, (const char **) argv);}EndCfn NSApplicationMain(0,0)'---------------
Let me know if you encounter problems. It's a little tricky getting everything hooked up just right, but it should work.Steve Van Voorst
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Posted by: svanvoorst <svanvoorst@...>
It appears that we now have a way to use FB to create Cocoa windows that use Cocoa events. I have done this once, but need others to reproduce the findings. For those willing, please try the following:
You will need 3 items: 1) Cocoa.xib created with IB, 2) Info.plst with 2 fields "Main nib file base name" and Principal Class ( you can use a copy from the FBCocoa folder recently cited by rp on the FB list, just change the file base name to match what you have created) and 3) a FB file which I am posting below.
1) Create a cocoa .xib using IB with the Cocoa application template. There is already a window included, so just drag a push button to it and name the button "Beep". Also drag an NSObjectController to the window and rename it myController using the inspector. We are going to manually set the outlet and action using the library palette. Find "myController" in the list of objects and with "Classes" selected at the top of the window go to the bottom of the window and click on "Outlets". Hit the "+" button to add your own outlet. Type in "beepBtn" and set the Type field to "NSButton". Then select the "Actions" button and type in "soundOff" and leave the Type as "id". Save everything. Then go back to your window and Ctrl-Drag from the Controller to the "Beep" push button. When you do this you should see the "beepBtn"outlet which you just entered - go ahead and select this. Then reverse Ctrl-Drag from the "Beep" button back to "myController" and you should see the action "soundOff" - go ahead and select it as well. At this point everything should be hooked up. XCode is case sensitive so make sure you have no typos.
2) Make sure you have your info.plst with the file base name field correctly filled out. It should be the same as the name for your .xib
3) Copy this code into FB and compile with the Objective C. You should hear a beep when you push the button. Note that there is no RunApplicationEventLoop() in this code and the window is a cocoa window.
'---------------
/*
Written by S. Van Voorst {20110105}
*/
include resources "myFBCocoa.xib"
toolbox fn NSApplicationMain( SInt32, ptr ) = SInt32
BeginCDeclaration
@interface myController : NSObjectController
{
IBOutlet NSButton *beepBtn;
}
-(IBAction) soundOff:(id)sender;
@end //interface
EndC
BeginCFunction
@implementation myController
-(IBAction) soundOff:(id)sender
{
NSBeep();
}
@end //implementation
EndC
BeginCCode
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSObjectController *myController = [[NSObjectController alloc]init];
[myController release];
[pool drain];
return NSApplicationMain(argc, (const char **) argv);
}
EndC
fn NSApplicationMain(0,0)
'---------------
Let me know if you encounter problems. It's a little tricky getting everything hooked up just right, but it should work.
Steve Van Voorst
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Click for thumbs down.0Click for thumbs up.0