Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    user area - drop finished

    PYTHON Development
    0
    5
    845
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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..."
        
      
      
      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

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

          Thanks Yannick,

          work great

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              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.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post