Announcement

Collapse
No announcement yet.

On Drag Cancelled question (drag and drop operation)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    On Drag Cancelled question (drag and drop operation)

    Hi,

    I'm making an inventory. Everything is working fine. I'm just looking for a way to drop an item outside of the inventory and spawn it back into the world.
    Now I already have this working perfectly.

    The only problem is when i drop my item on another slot, it also spawns it in the world everytime.

    The way I currently detect if an item is being dragged outside of the inventory is by using the "On drag cancelled" event from drag and drop operation.
    Now this always seems to fire when I release my dragged item (widget), regardless of it being dropped onto another slot. Now how would make it so cancelled it only called when there is no drop event?

    this is my drop
    Click image for larger version

Name:	db3a32a1eb2188ae362a734e81a0a8db.png
Views:	1
Size:	179.4 KB
ID:	1201292

    cancelled event (event graph)
    Click image for larger version

Name:	2fc81fe2a9b4a16123b4dba182ff756b.png
Views:	1
Size:	145.6 KB
ID:	1201293

    This is all inside a single inventoryslot widget

    #2
    I don't think its a good idea to handle spawning actors inside the "OnDragCancelled". This will always fire, even if the player obviously wants to do nothing.
    Instead you should make a canvas widget that has all the screen space, and in it, handle drop operations by spawning the actor.
    That widget should obviously ignore anything else - and not have a texture. Also the canvas must have a lower Zorder than your inventoryslot widgets

    Then on the OnDragCancelled you can actually handle what happens when the drag is cancelled (maybe nothing?)

    Also - I think that the reason it fires even when the drop is successfull is because you are not using the return nodes. You should use a "true" boolean for return value when the drag was successfull on your first screenshot
    Last edited by Semitable; 12-01-2016, 11:02 AM.
    Check my User Interface Kit here: https://forums.unrealengine.com/show...-Interface-Kit
    A WIP Hex Planet Generation: https://forums.unrealengine.com/show...ral-Generation

    Comment


      #3
      Originally posted by Semitable View Post
      I don't think its a good idea to handle spawning actors inside the "OnDragCancelled". This will always fire, even if the player obviously wants to do nothing.
      Instead you should make a canvas widget that has all the screen space, and in it, handle drop operations by spawning the actor.
      That widget should obviously ignore anything else - and not have a texture. Also the canvas must have a lower Zorder than your inventoryslot widgets

      Then on the OnDragCancelled you can actually handle what happens when the drag is cancelled (maybe nothing?)

      Also - I think that the reason it fires even when the drop is successfull is because you are not using the return nodes. You should use a "true" boolean for return value when the drag was successfull on your first screenshot
      OMG.. That fixed it. Thanks! xD

      Oh and the reason why I use "drag cancel" is because the slots I have in my inventory are all placed next to eachother without any space in between. So technically you can't cancel your drop. You can only drop it on a another slot, or when you are not dropping it ot another slot you are always droppig it out of the inventory basically in which case it needs to spawn in front of the player. But I see what you mean. In case I had an inventory with big borders and padding or something, there could be a scenario where you would accidently drop it on that and you'd want the drag operation to be cancelled and the object to return to it's previous slot. But as mentioned my inventory has no spaces in between. It's either a slot or nothing. And in case of nothing it always needs to drop in the world.
      Last edited by WixZ; 12-01-2016, 12:45 PM.

      Comment


        #4
        Originally posted by WixZ View Post
        OMG.. That fixed it. Thanks! xD

        Oh and the reason why I use "drag cancel" is because the slots I have in my inventory are all placed next to eachother without any space in between. So technically you can't cancel your drop. You can only drop it on a another slot, or when you are not dropping it ot another slot you are always droppig it out of the inventory basically in which case it needs to spawn in front of the player. But I see what you mean. In case I had an inventory with big borders and padding or something, there could be a scenario where you would accidently drop it on that and you'd want the drag operation to be cancelled and the object to return to it's previous slot. But as mentioned my inventory has no spaces in between. It's either a slot or nothing. And in case of nothing it always needs to drop in the world.
        Glad you fixed it.
        I was mostly talking about giving the player a way to cancel his operation. (He might want to do so with right-click or "esc"). Something user friendly and intuitive. But I guess that's up to you and your game - if it works for you then it's fine! :-)
        Check my User Interface Kit here: https://forums.unrealengine.com/show...-Interface-Kit
        A WIP Hex Planet Generation: https://forums.unrealengine.com/show...ral-Generation

        Comment


          #5
          Originally posted by Semitable View Post
          Glad you fixed it.
          I was mostly talking about giving the player a way to cancel his operation. (He might want to do so with right-click or "esc"). Something user friendly and intuitive. But I guess that's up to you and your game - if it works for you then it's fine! :-)
          Yeah true. Well, right now the inventory works perfectly fine the way it is. But if a need for a cancel arrives I will definitely consider your advice!

          Comment

          Working...
          X