This is such a classic example that most new to UE4 would go crazy when run into this.(I think this graph is wiki worthy for new to intermediate level UE4 to learn from.)
so what’s possible solution then, first of course you need to get rid of disable click event since your whole logic depends on those event to happen.
But, the MouseXYClick value update however can not be solved when using tick, as tick event run independently regardless of your other event, so this type of branching problem need more careful solution.
What then assuming you still need to check for mouse moved range after click? first to come up is just using MouseX and MouseY axis event to check pixel range.
So same thing with tick could happen if you happen to click and drag at the same time, but you reduced the chance to cause this bug. Not really satisfied since it’s not guaranteed.
Now since we know click and drag can happened at the same time, how to avoid it trigger like in this graph(imagine event click is replaced with MouseX and MouseY)?
We can :
- have a gate right after event MouseX and MouseY that use right click pressed/release as open/close event
- set MouseXYClick right before the execution line enter the gate
So we make sure that what ever runiing behind the gate is guaranteed to get latest MouseXYClick position even if you click and dragged(really easy to happen if you have a high dpi mouse). - we can then have a branch later after gate that determined if we choose to update view mode or not.
Here is my proposed solution, I encourage anyone visited this thread to give it a go and see if you can come up with a better solution and post here.
I really think this is wiki worthy stuff for people to think about, so maybe we have a proper before and after, with multiple solution and put a wiki page for future reference.