Drag&drop from GeUserArea [SOLVED]

On 15/11/2013 at 07:23, xxxxxxxx wrote:

User Information:
Cinema 4D Version:    
Platform:   Windows  ; Mac  ;  
Language(s) :     C++  ;

---------
Hi all,
i need to do a implementation for starting a drag&drop from GeUserArea to Material Manager or over the objects. But can't found any clue how can start this operation with DragAndDrop structure. I want to same thing which is done by material manager.
Any help will welcome,
Best

On 16/11/2013 at 06:06, xxxxxxxx wrote:

If I remember correctly, this will need to be handled by a SceneHook plugin.  Override the Message() method and check for these (as needed) :

MSG_DESCRIPTION_CHECKDRAGANDDROP ``MSG_MATERIALDRAGANDDROP ``MSG_DRAGANDDROP

On 16/11/2013 at 11:25, xxxxxxxx wrote:

I was curious about this. So I gave it a try myself.
But I can't get the messages to fire in my SceenHook plugin for some reason.
What else is needed for a message to execute?

Bool MySceneHook::Message(GeListNode *node, LONG type, void *data)  
{  
  BaseDocument *doc = GetActiveDocument();  
  BaseObject *obj = doc->GetFirstObject();  
  if(!obj) return FALSE;  
  
  MaterialDragAndDrop mdd;                 //Create an instance of the MaterialDragAndDrop struct (class)  
  mdd.op = obj;                            //Point to this object  
  //if(mdd.op) GePrint(mdd.op->GetName()); //works..But prints all the time. Not just when dropping a material on the obj  
  
  if(type == MSG_MATERIALDRAGANDDROP)  
  {  
      GePrint(mdd.op->GetName());         //<---Not working! :-(  
  }  
  
  if(type == MSG_DESCRIPTION_CHECKDRAGANDDROP)  
  {  
      GePrint(mdd.op->GetName());         //<---Not working! :-(  
  }  
  
  if(type == MSG_DRAGANDDROP)  
  {  
      GePrint(mdd.op->GetName());         //<---Not working! :-(  
  }  
  
  
  return TRUE;  
}

-ScottA

On 17/11/2013 at 06:05, xxxxxxxx wrote:

If that is the case, then these might only be sent to a recipient plugin 'object' (checking in its Message() method).  That would mean there is no way to handle general drag-and-drop as the op intends.

On 17/11/2013 at 10:01, xxxxxxxx wrote:

Thanks, but it's very annoying to can't do it. I hope any devs can give a hand for that. I have developped a custom browser over GeUserArea but i cannot drag&drop; materials from to any where.

On 17/11/2013 at 10:05, xxxxxxxx wrote:

i forgot to say, as you know GeUserArea can detect the dropped materials...
this for getting:

  case BFM_DRAGRECEIVE:


         {


            String string, str;


            LONG type = 0;


            void \*object = NULL;


            C4DAtomGoal \*bl = NULL;


  



            GetDragObject(msg,&type,&object);


  



            if (type==DRAGTYPE_ATOMARRAY && ((AtomArray\* )object)->GetCount()==1 && ((AtomArray\* )object)->GetIndex(0))


            {


                bl = (C4DAtomGoal\* )((AtomArray\* )object)->GetIndex(0);


       


                if (bl->IsInstanceOf(Mmaterial))


                {


                    str += "Mmaterial";


                }


            }

On 17/11/2013 at 11:07, xxxxxxxx wrote:

^Thanks for posting that code khor.
I didn't have that one in my notes.

-ScottA

On 17/11/2013 at 13:03, xxxxxxxx wrote:

you're welcome. If it helps i can completed last part as:

         case BFM_DRAGRECEIVE:


         {


            String string, str;


            LONG type = 0;


            void \*object = NULL;


            C4DAtomGoal \*bl = NULL;


  



            GetDragObject(msg,&type,&object);


  



            if (type==DRAGTYPE_ATOMARRAY && ((AtomArray\* )object)->GetCount()==1 && ((AtomArray\* )object)->GetIndex(0))


            {


                bl = (C4DAtomGoal\* )((AtomArray\* )object)->GetIndex(0);


                if (bl->IsInstanceOf(Mmaterial))


                {


                    str += "Mmaterial";


                }


            }


            else


                str = str+"unknown object";


  



            if (msg.GetLong(BFM_DRAG_FINISHED))  info("Dropped..."+str);


  



             return SetDragDestination(MOUSE_POINT_HAND);


             break;


         }

On 17/11/2013 at 13:54, xxxxxxxx wrote:

Thanks again.

That handles dragging things ** to** the UA nicely.
Now we just need someone to post how to handle dragging from the UA.

-ScottA

On 18/11/2013 at 15:40, xxxxxxxx wrote:

i found a hacked way for drag from a GeUserArea to another  GeUserArea. I'm testing now .
But still really need help for native method

On 23/03/2015 at 02:45, xxxxxxxx wrote:

Hello khor, did you find a solution to start a drag from a User Area? I need to do this as well, and I
have doubts it will be possible from Python if even from C++. :cry:

On 23/03/2015 at 07:59, xxxxxxxx wrote:

Hi,

I'm not sure I'm getting this right, but in order to start a mouse drag from a GeUserArea you simply call HandleMouseDrag from GeUserArea class.
I don't think the function exists in Python. Or if it does, it's at least undocumented.

On 23/03/2015 at 08:12, xxxxxxxx wrote:

Hi Andreas,

thanks, seems like I missed this method. Maybe I can work around this method missing from
with a C++ Plugin somehow.

On 23/03/2015 at 08:22, xxxxxxxx wrote:

Just verified, HandleMouseDrag is not available in Python.