On 01/11/2014 at 22:38, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;
---------
Hi Folks,
is it possible to put an object held in memory into a custom gui link field? I've copied and pasted some code I was using elsewhere that sets an object from the AM (drag and drop etc) but the process doesn't appear to work for objects in memory. The objects are made via GetClone() of an object that's dragged into the link field. When the link fields are redrawn however, I cannot see the object in the link. Process is a bit like as follow:
(Plugin is an object generator, links are made inside a customgui plugin)
1. Drag and drop an object into the link field
2. Check that object is not null
3. If not null, clone to class level reference: obj_cl = obj->GetClone(COPYFLAGS_0,NULL)
4. Flush and redraw the link field(s)
5. Apply object in memory to the new link field
6. Test print object's name
Code is simple, follows a similar process to the below:
BaseDocument *doc = GetActiveDocument();
BaseList2D *List_Link = LinkFields->GetLink(doc);
BaseObject *obj = (BaseObject* )List_Link;
if(obj != NULL)
{
// FUNCTION CALLED TO CLONE OBJECT
My_Obj->CloneObject(Link_id,obj); // see function below)
(..flush tab, redraw links here - needed for another purpose..)
// LinkFields = class level customgui link element
// Apply the cloned object to the newly drawn link field
LinkFields->SetLink(Obj_cl);
// Obj_cl is valid (GetName() print's fine) but doesn't show in link field
}
void PLUGIN_OBJECT::CloneObject(int id,BaseObject* obj)
{
// Note: Link_id is just an index (int). Not used in this example.
// Obj_cl is class level baseobject variable.
Obj_cl = obj->GetClone(COPYFLAGS_0,NULL);
GePrint("Cloned object's name = " + Obj_cl->GetName());
// Cloned object's name prints fine.
}
Only two rules need to be followed, the object must be a clone, and the clone must sit in memory. If the above doesn't work because it's just not possible, then is there a workaround (something else) I could use/do instead?
Cheers,
WP.
P.S. just an after thought, can a dialog's AddEditText() field receive a drag and drop message?