Skip to content

Commit fdbbd4e

Browse files
Keymap & Platform fixes
Previously the keymap list was cleared, but the items on the list were not actually removed from the keymap first, this update addresses that and any other outstanding keymap issues. sys.platform has been replaced with platform.system and `__package__` has been replaced with `__main__`, per recommendations.
1 parent 3b4d435 commit fdbbd4e

3 files changed

Lines changed: 30 additions & 83 deletions

File tree

RightMouseNavigation.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import bpy
22
from bpy.types import Operator
3-
import ctypes
4-
import sys
3+
import platform
54

65

76
class RMN_OT_right_mouse_navigation(Operator):
@@ -79,9 +78,6 @@ def reset_cursor():
7978
if space_type == 'VIEW_3D' or space_type == 'NODE_EDITOR' and enable_nodes:
8079
if event.type in {'RIGHTMOUSE'}:
8180
if event.value in {'RELEASE'}:
82-
if sys.platform.startswith('win'):
83-
# This fakes a Right Mouse Up event using Ctypes
84-
ctypes.windll.user32.mouse_event(self.MOUSE_RIGHTUP)
8581
# This brings back our mouse cursor to use with the menu
8682
context.window.cursor_modal_restore()
8783
# If the length of time you've been holding down
@@ -100,17 +96,25 @@ def reset_cursor():
10096
return {'PASS_THROUGH'}
10197

10298
def callMenu(self, context):
103-
if context.space_data.type == 'NODE_EDITOR':
104-
if context.space_data.node_tree:
105-
if context.space_data.node_tree.nodes.active is not None and context.space_data.node_tree.nodes.active.select:
106-
bpy.ops.wm.call_menu(name='NODE_MT_context_menu')
107-
else:
108-
bpy.ops.wm.search_single_menu('INVOKE_DEFAULT', menu_idname='NODE_MT_add')
99+
select_mouse = context.window_manager.keyconfigs.active.preferences.select_mouse
100+
space_type = context.space_data.type
101+
102+
if select_mouse == 'LEFT':
103+
if space_type == 'NODE_EDITOR':
104+
node_tree = context.space_data.node_tree
105+
if node_tree:
106+
if node_tree.nodes.active is not None and node_tree.nodes.active.select:
107+
bpy.ops.wm.call_menu(name='NODE_MT_context_menu')
108+
else:
109+
bpy.ops.wm.search_single_menu('INVOKE_DEFAULT', menu_idname='NODE_MT_add')
110+
else:
111+
try:
112+
bpy.ops.wm.call_menu(name=self.menu_by_mode[context.mode])
113+
except RuntimeError:
114+
bpy.ops.wm.call_panel(name=self.menu_by_mode[context.mode])
109115
else:
110-
try:
111-
bpy.ops.wm.call_menu(name=self.menu_by_mode[context.mode])
112-
except RuntimeError:
113-
bpy.ops.wm.call_panel(name=self.menu_by_mode[context.mode])
116+
if space_type == 'VIEW_3D':
117+
bpy.ops.view3d.select('INVOKE_DEFAULT')
114118

115119
def invoke(self, context, event):
116120
# Store Blender cursor position

__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,7 @@ def unregister():
8686

8787
wm = bpy.context.window_manager
8888
active_kc = wm.keyconfigs.active
89-
90-
for key in active_kc.keymaps['Node Editor'].keymap_items:
91-
if (key.idname == 'rmn.right_mouse_navigation'):
92-
active_kc.keymaps['Node Editor'].keymap_items.remove(key)
93-
94-
addon_keymaps.clear()
89+
addon_kc = wm.keyconfigs.addon
9590

9691
menumodes = ["Object Mode", "Mesh", "Curve", "Armature",
9792
"Metaball", "Lattice", "Font", "Pose", "Node Editor"]
@@ -133,6 +128,11 @@ def unregister():
133128
key.type = "LEFTMOUSE"
134129
key.value = "PRESS"
135130

131+
for km in addon_kc.keymaps:
132+
for kmi in km.keymap_items:
133+
km.keymap_items.remove(kmi)
134+
addon_keymaps.clear()
135+
136136

137-
if __name__ == "__package__":
137+
if __name__ == "__main__":
138138
register()

blender_manifest.toml

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,16 @@
11
schema_version = "1.0.0"
22

3-
# Example of manifest file for a Blender extension
4-
# Change the values according to your extension
53
id = "right_mouse_navigation"
6-
version = "2.3.3"
4+
version = "2.3.8"
75
name = "Right Mouse Navigation"
8-
tagline = "Game Engine-style viewport & node graph navigation"
6+
tagline = "Game Engine-style Viewport & Node Navigation"
97
maintainer = "Spectral Vectors"
10-
# Supported types: "add-on", "theme"
118
type = "add-on"
129

13-
# Optional link to documentation, support, source files, etc
1410
website = "https://github.com/SpectralVectors/RightMouseNavigation"
1511

16-
# Optional list defined by Blender and server, see:
17-
# https://docs.blender.org/manual/en/dev/advanced/extensions/tags.html
18-
tags = ["Animation", "Sequencer"]
12+
tags = ["3D View", "Node", "User Interface"]
1913

2014
blender_version_min = "4.2.0"
21-
# # Optional: Blender version that the extension does not support, earlier versions are supported.
22-
# # This can be omitted and defined later on the extensions platform if an issue is found.
23-
# blender_version_max = "5.1.0"
2415

25-
# License conforming to https://spdx.org/licenses/ (use "SPDX: prefix)
26-
# https://docs.blender.org/manual/en/dev/advanced/extensions/licenses.html
27-
license = [
28-
"SPDX:GPL-2.0-or-later",
29-
]
30-
# Optional: required by some licenses.
31-
# copyright = [
32-
# "2002-2024 Developer Name",
33-
# "1998 Company Name",
34-
# ]
35-
36-
# Optional list of supported platforms. If omitted, the extension will be available in all operating systems.
37-
# platforms = ["windows-x64", "macos-arm64", "linux-x64"]
38-
# Other supported platforms: "windows-arm64", "macos-x64"
39-
40-
# Optional: bundle 3rd party Python modules.
41-
# https://docs.blender.org/manual/en/dev/advanced/extensions/python_wheels.html
42-
# wheels = [
43-
# "./wheels/hexdump-3.3-py3-none-any.whl",
44-
# "./wheels/jsmin-3.0.1-py3-none-any.whl",
45-
# ]
46-
47-
# # Optional: add-ons can list which resources they will require:
48-
# # * files (for access of any filesystem operations)
49-
# # * network (for internet access)
50-
# # * clipboard (to read and/or write the system clipboard)
51-
# # * camera (to capture photos and videos)
52-
# # * microphone (to capture audio)
53-
# #
54-
# # If using network, remember to also check `bpy.app.online_access`
55-
# # https://docs.blender.org/manual/en/dev/advanced/extensions/addons.html#internet-access
56-
# #
57-
# # For each permission it is important to also specify the reason why it is required.
58-
# # Keep this a single short sentence without a period (.) at the end.
59-
# # For longer explanations use the documentation or detail page.
60-
#
61-
# [permissions]
62-
# network = "Need to sync motion-capture data to server"
63-
# files = "Import/export FBX from/to disk"
64-
# clipboard = "Copy and paste bone transforms"
65-
66-
# Optional: build settings.
67-
# https://docs.blender.org/manual/en/dev/advanced/extensions/command_line_arguments.html#command-line-args-extension-build
68-
# [build]
69-
# paths_exclude_pattern = [
70-
# "__pycache__/",
71-
# "/.git/",
72-
# "/*.zip",
73-
# ]
16+
license = ["SPDX:GPL-2.0-or-later"]

0 commit comments

Comments
 (0)