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"

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 :

     if (!InViewport->HasMouseCapture() || !InViewport->HasFocus() || (ViewportConsole && ViewportConsole->ConsoleActive()))
     {
         return EMouseCursor::Default;
     }

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

 if ((!InViewport->HasMouseCapture() && !InViewport->HasFocus()) || (ViewportConsole && ViewportConsole->ConsoleActive()))

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)

Product Version: Not Selected
Tags:
more ▼

asked Dec 01 '14 at 03:30 PM in Bug Reports

avatar image

rajkosto
188 23 31 144

avatar image Thokash Dec 10 '14 at 11:08 PM

I've been having this exact problem since before 4.6 but I'm using blueprints entirely, no code at all. I hope that can help you narrow down what's causing the problem because I can't figure it out. It's really frustrating. I only get the cursor change if a mouse button is being held.

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

3 answers: sort voted first

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.

more ▼

answered Dec 16 '14 at 11:38 PM

avatar image

Tim C ♦♦ STAFF
18.2k 423 69 286

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

Hi rajkosto,

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.

Tim

more ▼

answered Dec 05 '14 at 09:23 PM

avatar image

Tim C ♦♦ STAFF
18.2k 423 69 286

avatar image rajkosto Dec 05 '14 at 09:25 PM

Yes i just mentioned that i do not want the mouse captured.

avatar image Tim C ♦♦ STAFF Dec 10 '14 at 11:00 PM

It looks like a fix for this was implemented today. Once we have a stable internal build that contains the fix I'll run through my tests again to make sure it is working as expected.

I also just wanted to make sure I am completely clear on the mouse capture issue. Are you actually seeing your mouse being captured in the viewport?

Tim

avatar image rajkosto Dec 10 '14 at 11:02 PM

No. The only reason i mentioned capturing is because the buggy condition for showing the correct mouse cursor is that it has to be captured.

avatar image Tim C ♦♦ STAFF Dec 10 '14 at 11:08 PM

Ok. I didn't see that happening when I was running tests using the workaround you provided. I'll make sure to look for that when I can test the Engine again with the fix in place.

avatar image rajkosto Dec 10 '14 at 11:18 PM

That's because you had the workaround on. I'm using it as well and it's "fine" for me but i dont know if its correct for all situations.

avatar image Thokash Dec 10 '14 at 11:21 PM

If you don't mind me asking, what is the workaround you're mentioning? I've tried what's listed in this post and I'm still having the same issue.

avatar image rajkosto Dec 10 '14 at 11:22 PM

Change the line in GameViewportClient.cpp

avatar image Tim C ♦♦ STAFF Dec 10 '14 at 11:26 PM

Hi Thokash,

rajkosto had provided a workaround that involves a change to a line in the source code. If you are working in a binary version of the Engine installed by the Launcher, then you wouldn't be able to make that change.

Have you tried the process that Rudy mentioned in his answer to this post?

avatar image Thokash Dec 10 '14 at 11:35 PM

Well in that case I won't be able to make that change. And yeah, I already had something similar. Attached is a function I have that's run off of eventTick. I've tried this, changing mouse cursor within each object (based off of cursorOverBegin/End events), and messing with the playerController defaults. Each has the same results. I get the expected cursor change ONLY if left/right click is held down. Otherwise it's always the default mouse cursor.

alt text

problem 01.jpg (264.3 kB)
problem 02.jpg (268.2 kB)
avatar image Thokash Dec 10 '14 at 11:40 PM

I should add that other things that are driven by mouseOver events work well. Each of my units has a little selection decal underneath them that appears on mouseOver and disappears on mouseOverEnd. Those work fine. I have a blendable highlight on some units that work off of mouseOver and those work fine, too. The only thing that's not working is cursor changing.

I'm doing kind of an RTS thing and at first you could switch between RTS and third person. Well when in TP you had no cursor. Upon switching over to RTS mode the cursor would appear and mouseOver-controlled cursor switching worked UNTIL I left/right clicked once. After that I got the problem we've been talking about. Also, maybe worth noting, when it was working, my mouse couldn't leave the viewport. Once I clicked, it stopped working properly and my mouse could once again leave the viewport. Each time I'd switch from TP to RTS, it would work until that one click. I could repeat this as many times as I wanted. But obviously, you shouldn't have to remove your cursor and show it every time you want a cursor switch to work. Although I haven't tried doing that... I'll try doing that and let you know how it works.

avatar image rajkosto Dec 10 '14 at 11:41 PM

It doesn't matter. They broke CurrentMouseCursor in 4.6 so it's only used when the buttons are held down. Wait for fix or apply workaround.

avatar image Thokash Dec 10 '14 at 11:45 PM

Well for me this problem has been going on since 4.4. It's never worked for me.

avatar image Thokash Dec 10 '14 at 11:55 PM

Also looks like disabling then enabling the mouse cursor doesn't work. Tried every combination of mouse/cursor options.

avatar image Rudy Q ♦♦ STAFF Dec 11 '14 at 03:48 PM

Hello Thokash,

I looked over the screen shot that you provided and was unable to gather enough information to provided any suggestions. Could you post a more complete picture of the blueprints that you are using?

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

Hello rajkosto,

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:

alt text

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

undermousehelp.png (374.7 kB)
more ▼

answered Dec 04 '14 at 08:53 PM

avatar image

Rudy Q ♦♦ STAFF
47.5k 545 132 522

avatar image rajkosto Dec 04 '14 at 09:11 PM

I get that, and that's basically what my code is doing (setting CurrentMouseCursor in PlayerController). The issue is that if bShowMouseCursor is true on the defaults of PlayerController, CurrentMouseCusror in PlayerController never ends up getting used, because of that check i've shown.

avatar image Rudy Q ♦♦ STAFF Dec 04 '14 at 09:44 PM

Hello rajkosto,

I tried setting up the default for my player controller to set show mouse as true. I then disabled my "set show mouse cursor" node in my blueprints. The mouse appears to be updating as expected (changing from cross hair to hand to default). I am going to shoot Tim Lincoln an email and get him to try it out in code to see if there is a difference.

(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