Hi Christopher, Le 13 avr. 2011 à 14:31, Christopher Armstrong a écrit :
> I'm mucking around with integrating ObjectMerging4 with EtoileUI, and I'm > stuck on a problem with instantiating new objects. > > I've got an application controlled by a NSDocumentController. You mean ETDocumentController, right?… given that NSDocument-architecture is not compatible with EtoileUI. > Each document is just an array of objects to which more objects can be added, > with its own controller. I'm creating a new persistent editing context per > document and storing it as a property of the root layout item for that > document. > > When the user selects "Add", its supposed to instantiate a new object and add > it to the list. This object needs to be instantiated in the editing context > of the document, so I need to get to the root item of the current document in > order to create it. I'm using an ETItemTemplate subclass to try and do this, > but I can't work out how to get to the current document in the application. I > looked at using the +[ETTool activeTool] but it doesn't seem to be connected > to a responder. [[ETTool activeTool] keyItem] should return what you want. See also -[ETTool mainItem] that corresponds to the main window (-keyItem corresponds to the key window). What do you mean by the active tool doesn't seem to be connected to a responder? Both Frameworks/EtoileUI/MarkupEditor and Developer/Services/ModelBuilder might interest you btw, to see how to use ETDocumentController, ETController and ETItemTemplate. > Would anyone have an idea how to go about this, or be able to suggest an > alternative approach? If you use ETDocumentController, you can send -activeItem to it to get the frontmost item that corresponds to the current document. That would be the recommended way. Cheers, Quentin. _______________________________________________ Etoile-dev mailing list Etoile-dev@gna.org https://mail.gna.org/listinfo/etoile-dev