user area - drop finished



  • On 06/03/2015 at 12:06, xxxxxxxx wrote:

    I try to revive a drag and drop on a user area but I don`t get the finished

    def Message(self, msg, result) :
            if msg.GetId() == c4d.BFM_DRAGRECEIVE:
                str = ""
                type = 0;
                object = None
                bl = None
                print "revice"
                dragobject = self.GetDragObject(msg)
                print dragobject
                if msg.GetLong(c4d.BFM_DRAG_FINISHED) :
                    print "  info(Dropped..."
      
    
    


  • On 09/03/2015 at 10:45, xxxxxxxx wrote:

    Hi,

    Drag and drop methods are not currently documented in GeUserArea and GeDialog but they are fully functioning. They will be documented in the near future.
    To receive drag and drop messages as expected it is important to return the appropriate values from Message() with SetDragDestination().
    Here is the code I added to the Py-MemoryViewer example:

    def Message(self, msg, result) :
      if msg.GetId()==c4d.BFM_DRAGRECEIVE:
        # Discard if lost drag or if it has been escaped
        if msg.GetInt32(c4d.BFM_DRAG_LOST) or msg.GetInt32(c4d.BFM_DRAG_ESC) :
          return self.SetDragDestination(c4d.MOUSE_FORBIDDEN)
        # Check drop area and discard if not on the user area
        if not self.CheckDropArea(msg, True, True) :
          return self.SetDragDestination(c4d.MOUSE_FORBIDDEN)
      
        print "Dragged"
      
        # Get drag object type and data
        draginfo = self.GetDragObject(msg)
      
        # Check if drag is finished (=drop)
        if msg.GetInt32(c4d.BFM_DRAG_FINISHED)==1:
          print "Dropped"
          return True
      
        # Return current mouse cursor for valid drag operation
        return self.SetDragDestination(c4d.MOUSE_MOVE)
      
      # Call GeUserAre.Message() implementation so that it can handle all the other messages
      return gui.GeUserArea.Message(self, msg, result)
    

    Note GetDragObject() returns a dictionary with 2 object "type" and "object" (in the code I prefer to assign these individually).
    MOUSE_POINT_HAND is returned for the current drag destination cursor but any other valid MOUSE value can be returned.

    EDIT: Updated code.



  • On 09/03/2015 at 16:49, xxxxxxxx wrote:

    Thanks Yannick,

    work great



  • On 10/03/2015 at 00:56, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    [...]

    def Message(self, msg, result) :
      if msg.GetId()==c4d.BFM_DRAGRECEIVE:
        # Discard if lost drag or if it has been escaped
        if msg.GetInt32(c4d.BFM_DRAG_LOST) or msg.GetInt32(c4d.BFM_DRAG_ESC) :
          return self.SetDragDestination(c4d.MOUSE_FORBIDDEN)
        # Check drop area and discard if not on the user area
        if not gui.GeUserArea.CheckDropArea(self, msg, True, True) :
          return self.SetDragDestination(c4d.MOUSE_FORBIDDEN)
     
        print "Dragged"
     
        # Get drag object type and data
        type, data = self.GetDragObject(msg)
     
        # Check if drag is finished (=drop)
        if msg.GetInt32(c4d.BFM_DRAG_FINISHED)==1:
          print "Dropped"
          return True
     
        # Return current mouse cursor for valid drag operation
        return self.SetDragDestination(c4d.MOUSE_MOVE)
     
      # Call GeUserAre.Message() implementation so that it can handle all the other messages
      return gui.GeUserArea.Message(self, msg, result)
    

    Note GetDragObject() returns a dictionary with 2 object "type" and "object" (in the code I prefer to assign these individually).
    MOUSE_POINT_HAND is returned for the current drag destination cursor but any other valid MOUSE value can be returned.

    I just want to point out that it is not guaranteed that the dictionary will
    unpack in the order you expect it, so you should definetly assign type
    and data seperately.

    Also, you can (should) use self.CheckDropArea(...) instead of
    c4d.gui.GeUserArea.CheckDropArea(self, ...).

    Best regards,
    Niklas



  • On 10/03/2015 at 02:02, xxxxxxxx wrote:

    Hi Niklas,

    Originally posted by xxxxxxxx

    I just want to point out that it is not guaranteed that the dictionary will
    unpack in the order you expect it, so you should definitely assign type
    and data separately.

    You're right. The code I posted doesn't actually unpack the drag object information dictionary from GetDragObject() as expected.

    Originally posted by xxxxxxxx

    Also, you can (should) use self.CheckDropArea(...) instead of
    c4d.gui.GeUserArea.CheckDropArea(self, ...).

    Yes it's better and it looks nicer to call CheckDropArea() on self instead.

    I updated the code I posted yesterday.


Log in to reply