CurrentMouseCursor set in PlayerController is only used when a Mouse Button is held down
I have bShowMouseCursor set to true in my project, and the default one shows up just fine, so i wanted to change it depending on what object I'm hovering over. I implemented the logic for that in my player controller's PlayerTick, using CurrentClickablePrimitive (bEnableMouseOverEvents is true for this variable to be valid), and I've confirmed that it sets CurrentMouseCursor on the PlayerController perfectly. However, I'm still getting the default mouse cursor when i hover over things, UNLESS I'm holding the left or mouse button down. Then my CurrentMouseCursor shows up.
Ive identified the culprit to be down to this in UGameViewportClient::GetCursor :
So the viewport needs to have BOTH MouseCapture AND Focus for it's cursor to show up. I've found it IMPOSSIBLE to get HasMouseCapture to return true UNLESS I'm actually holding a mouse button down (using the mouse capture interface doesn't seem to affect it, neither does lock or setfocustoviewport and all the other functions i've found).
So i've changed that line to
Which means the viewport needs to have mouse capture or focus, doesn't have to have both, and since it has focus, my set mouse cursor is respected. Is this expected behaviour ? Maybe i should be using hit proxies to set my mouse cursor when i'm hovering over world stuff ? I have no idea how to use those and documentation is non-existent, however. Is there a way to have HasMouseCapture on my viewport return true (and this is a RTS, i DO NOT want my mouse to be locked to the window or not be able to leave it in windowed mode, the user should be able to multitask with normal apps just fine)
asked Dec 01 '14 at 03:30 PM in Bug Reports
I just ran through my test with our latest internal build of the Engine, and it appears that the fix that was put in for this issue has resolved it. If you built the Engine from source code, you can find the commit that includes this fix here. If you are using a binary version of the Engine installed by the Launcher, the fix will be available in a future release version of the Engine.
answered Dec 16 '14 at 11:38 PM
I did some testing with this issue today, and initially I had the same results that Rudy was seeing. When I took a closer look at the source code though, I realized that you were using 4.6 and we were testing in 4.5.1. When I ran the same test in 4.6, I saw what you were describing. I have entered a report about this issue to have it investigated further (UE-6348).
I am not too sure what you were referring to with regards to the mouse being captured in the viewport. When I was testing this issue, as well as the workaround that you mentioned, I was able to move the mouse outside of the viewport. The only time the mouse appeared to be captured was when I was holding down one of the mouse buttons.
answered Dec 05 '14 at 09:23 PM
After looking into the issue, I believe that the mouse is working as intended. However, I have a blueprint that does what you have asked. Whenever the mouse is over an object in the scene it will change it's "Current Mouse Cursor". In this example whenever it is over a cube (BoxIsBox is the actor name) it will show as cross hairs. When ever it is over a sphere (sphereIsphere is the actor name) it will be a grabby hand. Finally whenever it is over none of these it will appear as the default cursor. This setup also allows the mouse to leave the window. I hope this helps.
My Character blueprint:
Note: This design could be improved by building in master classes so as to shorten the amount of "Branch" nodes that will need to be cycled through every frame.
Make it a great day
answered Dec 04 '14 at 08:53 PM
Rudy Q ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here