x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Drag widget and drop on actor.

There is already exactly the same question, but it was closed due to beautiful reason: https://answers.unrealengine.com/questions/536407/umg-to-actor-drag-drop-detection.html

Seems like drag'n'drop operation consumes mouse events. Is there an accessible event outside widgets so I could detect mouse release or drop on actor itself and could fix my current redneck solution? alt text

Product Version: UE 4.18
Tags:
more ▼

asked Apr 11 '19 at 06:46 AM in Blueprint Scripting

avatar image

Two-faced
842 31 12 47

avatar image HarryHighDef Apr 11 '19 at 09:25 AM

You can bind the mouse as an input and use that.

I'm also curious as to why you delay two frames before calling your interface?

avatar image Two-faced Apr 11 '19 at 11:59 PM

You can bind the mouse as an input and use that.

What do you mean?

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Extend the drag&drop operation - it has 3 overridable functions - Drop / Drag / Cancel - all returning pointer data. You can then line trace for world objects while dragging.

The Player Controller does not know what is happening to the cursor during the drag, the operation does. Details in my post here.

more ▼

answered Apr 11 '19 at 11:52 AM

avatar image

Everynone
13.7k 74 25 57

avatar image Two-faced Apr 12 '19 at 12:15 AM

Thanks man, does custom operation work with widgets or it stop being registered for some reason?

avatar image Everynone Apr 12 '19 at 07:04 AM

It only works with widgets. It's the same as the normal drag & drop operation but you can flesh it out with features.

It's like default Player Controller vs Your Own Fancy Player Controller. It allows you to add data and handle additional logic.

avatar image Two-faced Apr 12 '19 at 09:09 PM

So is internal event OnDrop called anyways even if you don't release LMB on widget?

avatar image Everynone Apr 12 '19 at 11:04 PM

It's not, no widget to drop on = no call. You can evoke drop cancelled, though. I'm actually unsure what is the purpose of Drop in the DragOperation. :|

The Dragged is super-useful for what you need - getting cursor position and checking what's underneath; deproject screen to world and trace.

I can't remember precisely, but you will most likely need to provide the drag & drop operation a reference to the player controller as these two normally can't see one another. This screenspace / world space interaction is not something UMG was designed for, it seems :|


There is another hackaround (apart from your crafty (!) 2 frame delay in order to read cursor data from the controller).

You can cover the entire screen with a visible canvas during drag - that canvas will know what is being dragged over it and where it's heading:

alt text

As you can see, it's possible to drive both a widget and a world object during the same tick like this. It's hacky but it does work. From here you can treat that cube as a collider and have it interact with the world.

avatar image Everynone Apr 12 '19 at 11:24 PM

Anyway, coming back to the non-hacky solution, here's a quick wrap up that actually does not require you to send player controller reference anywhere but uses a dynamic dispatcher bind instead:

The Custom Drag and Drop Operation firing a dispatcher with 2d vector:

alt text

Detecting Drag:

alt text

The Player Controller event (with 2d vector so the signatures match):

alt text

pc.png (125.4 kB)
dd.png (98.2 kB)
detectdrag.png (178.6 kB)
avatar image Two-faced Apr 13 '19 at 03:14 AM

Hmm so far it's seems that my solution wasn't so bad :D Anyways thanks for the interesting example! I'll mark your answer as appropriate, since Dragged is technically what I asked for.

(comments are locked)
10|2000 characters needed characters left
more ▼

answered Apr 11 '19 at 11:10 AM

avatar image

Mint Gorillaz
7 1 1 1

avatar image Two-faced Apr 12 '19 at 12:04 AM

Completely irrelevant and a link to a 20 min video instead of simple answer. Next time please consider respect people's time if you want to help them,

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question