|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Apprentice |
Anyone know how to load and use NIB files in F-script? I have been trying to translate from some Objective-C Cocoa tutorials but it isn't working and I have a feeling that F-script must have some different requirements.
In particular, when using something like NSBundle loadNibNamed:owner:or related initialization methods, I can't figure out what the owner object should be. The Objective-C tutorials all use owner:self but I don't think that will work when the NIB is loaded from a standalone script and not a class object. |
||
|
|
Marketcircle Team |
You would have to use a window controller or some such technique.
WindowController has a method called: initWithWindowNibPath:owner: Unfortunately you still need an owner which wrecks the plan. Did you look at the f-script examples in the f-script site. I think they have an example of how to load a nib. But since you are already coming from ObjectiveC, why don't you just make a plugin. It's pretty easy and we have examples of loading a window I believe. Look at the dev kit. |
|||
|
|
Apprentice |
If you don't have a nib's file owner object at hand, you can still get access to the top-level objects in the nib and, from there, to the whole object graph in the nib to do whatever you want. For example, the folowing code loads a nib file (in this case, the nib of Apple's Mail POP account details panel) and get the nib's top-level objects (in this particular case, there is just one) in an array named topLevelObjects.
" Define the path of the nib"
nibPath := '/Applications/Mail.app/Contents/Resources/English.lproj/POPAccountDetails.nib'.
" Create an empty array that will be populated with the nib's top level objects "
topLevelObjects := {}.
" Create a dictionary configured in order to pass our empty array to the nib loading method (see the Cocoa documentation)"
nameTable := NSDictionary dictionaryWithObject:topLevelObjects forKey:NSNibTopLevelObjects.
" Load the nib file and populate our array "
NSBundle loadNibFile:nibPath externalNameTable:nameTable withZone:nil.
"In this particular example, the nib contains a panel. Put it on screen."
(topLevelObjects at:0) orderFront:nil.
Best, Philippe Mougin |
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|

