# Detecting axis if user dragging mouse

**URL:** <https://forums.unrealengine.com/t/detecting-axis-if-user-dragging-mouse/390955>\
**Category:** UI\
**Tags:** drag, axis, detection, unreal-engine, Blueprint, question, UMG\
**Created:** [April 14, 2017, 11:46pm UTC](https://forums.unrealengine.com/t/detecting-axis-if-user-dragging-mouse/390955 "2017-04-14T23:46:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khubur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/khubur/32/1223964_2.png) [@Khubur](https://forums.unrealengine.com/u/Khubur)\
**Post date:** [April 14, 2017, 11:46pm UTC](https://forums.unrealengine.com/t/detecting-axis-if-user-dragging-mouse/390955/1 "2017-04-14T23:46:53Z")

</div>

Hey, there is any detection function or something like for if user is pressing left button and dragging mouse. How do I do detect it? I want to rotate right if user is pressing and rotating to right. ( I have rotation function for 3D object. )

---

<div class="post-metadata">

**Author:** ![vanlacke](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vanlacke](https://forums.unrealengine.com/u/vanlacke)\
**Post date:** [April 15, 2017, 2:48am UTC](https://forums.unrealengine.com/t/detecting-axis-if-user-dragging-mouse/390955/2 "2017-04-15T02:48:21Z")

</div>

You can “GetMousePosition” on click, store the x,y position. Then Determine which direction the mouse is moving based on that, using the same node - “GetMousePosition”

---

<div class="post-metadata">

**Author:** ![irdc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@irdc](https://forums.unrealengine.com/u/irdc)\
**Post date:** [April 18, 2017, 3:04pm UTC](https://forums.unrealengine.com/t/detecting-axis-if-user-dragging-mouse/390955/3 "2017-04-18T15:04:17Z")

</div>

Hi. When your player initially presses the left button, store the x and y position from GetMousePosition into a vector using the OnClick() node. It may be helpful to set a boolean like “MouseScrolling” to true when OnClick is used and set it to false when OnReleased() is triggered.

Then, use the OnTick() node on the Event Graph to check and see if MouseScrolling is true. If so, then run GetMousePosition again to get the current mouse position. Now compare the X vector of the GetMousePosition set during OnClick() with the GetMousePosition set during OnTick(). If the OnTick() X value is greater than the OnClick() X value, then the mouse has been moved to the right. If it is less, than it is being moved to the left. The same also applies with the Y vector.
