Skip to content

Commit 8b1c096

Browse files
Merge pull request #16 from NathanC/cursor-reset-change
Adds a preference for cusor reset behavior
2 parents fc2b4c2 + 4ec450f commit 8b1c096

4 files changed

Lines changed: 32 additions & 10 deletions

File tree

Preferences.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,18 @@ class RightMouseNavigationPreferences(bpy.types.AddonPreferences):
1919
max=200
2020
)
2121

22+
reset_cursor_on_exit: bpy.props.BoolProperty(
23+
name="Reset Cursor on Exit",
24+
description="After exiting navigation, this determines if the cursor resets to where RMB was clicked (if checked) or stays in the center (if unchecked)",
25+
default=True
26+
)
27+
2228
def draw(self, context):
2329
layout = self.layout
24-
row = layout.row()
25-
row.prop(self, 'timepreference')
26-
row.prop(self, 'distancepreference')
30+
31+
layout.label(text="Menu Trigger Preferences")
32+
layout.prop(self, 'timepreference')
33+
layout.prop(self, 'distancepreference')
34+
35+
layout.label(text="Cursor Preferences")
36+
layout.prop(self, 'reset_cursor_on_exit')

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Mouse Wheel to adjust Viewport Move Speed (while Right Mouse is held)
1818

1919
You can adjust the threshold for when you navigate/open menus by adjusting the time the mouse button is held, or distance the cursor travels in __Edit__ > __Preferences__ > __Addons__ > __View 3D: Right Mouse Navigation__ by clicking the dropdown arrow and tweaking the values there.
2020

21+
Additionally, in the settings, you can change the cursor resetting behavior. By default, the cursor will snap back to the location where you initally clicked Right Mouse Button, after navigation exits. If you would rather the cursor stay in the center (where the navigation crosshair is) after navigation, you can disable the setting.
22+
2123
## Acknowledgements and Thanks
2224

2325
Big thanks to __Biaru__ for fixing the context menu/cursor location bug, and adding a 'mouse movement' threshold, in addition to the time threshold for fine-tuning when you navigate vs open the context menu!

RightMouseNavigation.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,23 @@ def modal(self, context, event):
2929

3030
# The _finished Boolean acts as a flag to exit the modal loop,
3131
# it is not made True until after the cancel function is called
32-
if self._finished == True:
33-
# Reset blender window cursor to previous position
34-
context.window.cursor_warp(self.view_x, self.view_y)
35-
# Reset Windows OS cursor to previous position
36-
ctypes.windll.user32.SetCursorPos(self.mouse_x, self.mouse_y)
37-
if self._callMenu == True:
32+
if self._finished:
33+
34+
def reset_cursor():
35+
# Reset blender window cursor to previous position
36+
context.window.cursor_warp(self.view_x, self.view_y)
37+
# Reset Windows OS cursor to previous position
38+
ctypes.windll.user32.SetCursorPos(self.mouse_x, self.mouse_y)
39+
40+
if self._callMenu:
41+
# Always reset the cursor if menu is called, as that implies a canceled navigation
42+
reset_cursor()
3843
self.callMenu(context)
44+
else:
45+
# Exit of a full navigation. Only reset the cursor if the preference (default False) is enabled
46+
if addon_prefs.reset_cursor_on_exit:
47+
reset_cursor()
48+
3949
return {'CANCELLED'}
4050

4151
if context.space_data.type == 'VIEW_3D':

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'name': 'Right Mouse Navigation',
33
'category': 'View 3D',
44
'author': 'Spectral Vectors',
5-
'version': (0, 1, 8),
5+
'version': (0, 1, 9),
66
'blender': (2, 90, 0),
77
'location': '3D Viewport',
88
"description": "Enables Right Mouse Viewport Navigation"

0 commit comments

Comments
 (0)