Hey there, I’m new here
First of all, this is in the context of a mod for Conan so Unreal Engine 4.15.3 and there are certain things that are “off limits”.
The reason for posting here is that it’s basic Unreal widget related stuff and trying to find a workaround, plus there aren’t a whole lot of people making elaborate Conan mods
Long story short, I have a Widget as part of the HUD and I am attempting to allow the user to move it around with the mouse in a click and drag style but only from a window header bar.
I have tried 2 different methods… both of them seem to work to some extent, however both have their issues.
- First I tried the simpler approach by making a button in the header and on-press setting up an event timer that got the mouse coordinates and updated the window position to then invalidate the timer on mouse button release…
The issue here is that in unreal 4.15 I only have access to GetMousePositionScaledbyDPI from the player controller, there is no GetMousePositionOnViewport sadly… and while it “would” work, the issue is on drag the cursor position doesn’t update (I think this is either a bug in U4.15 or just a side-effect of not having the cursor on drag) so it makes the widget stay put as it cannot get the new mouse coordinates.
As a workaround I tried doing it “onclicked” instead of down and up and just use a flip-flop… That works… I can click the titlebar… release the mouse button and the widget will follow my cursor then I can click again to place it… It’s just really wonky and quite counter-intuitive in 2022 I must say (reminds me of very old software from like windows 95 )
- So I tried implementing a “better” method… which would be to make a separate titlebar widget just to have something to click on, override the “on mouse down”, “on mouse up” get the offset from there and call an event dispatcher which I bound an event to on my main widget event graph - where I implemented an “on mouse move” override to simply store the coordinates in a variable, finally I’m updating the position of the parent widget on tick to the move coordinates if the event was called and stopping that when the mouse up dispatcher is called.
This one works pretty well in that you can actually drag the window around smoothly without a click-and-release like with the previous method…
Sadly, this too has issues…
Firstly I am unable to get coordinates from the canvas itself while moving the mouse around. So the geometry only contains the proper mouse coordinates whenever I hover on any actual widget element…
This causes issues because if you move the mouse even remotely fast over empty space where you don’t have elements belonging to this widget BP the widget movement will stop as its unable to get the mouse coordinates.
To rectify this I added a completely transparent border filling my whole canvas… this appears to make the dragging operation completely smooth and it’s able to function over most of the space - however it will still stop if I’m over other elements not added in my widget blueprint (like the basic game HUD, or chat, anything with a higher Z-index as my widget) - so this is still an issue as I can’t cover the basic game UI with a transparent thing that you cannot click through.
The other issue is that even though the coords appear to be translated properly, since it’s just a titlebar - being a fairly narrow area - I’ll often find that when I stop the drag operation my mouse isn’t exactly on the bar so the “mouse up” dispatcher won’t fire since I’m no longer over that widget, making the widget permanently follow my cursor at an offset to where I can’t even click the bar again.
Long story short… I’m trying to find some way of making this a bit less clunky and I’m running out of ideas so here I am
(Keep in mind that due to the nature of the project I am unable to do certain stuff, for example setting the input to UI or Game or toggling the cursor flag does absolutely nothing since Conan has its own GUIModule controller which immediately overrides any changes made)
Thanks in advance!