Skip to content

Commit c161511

Browse files
Keymap in Preferences
1 parent 0d230cc commit c161511

File tree

3 files changed

+52
-9
lines changed

3 files changed

+52
-9
lines changed

Preferences.py

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,61 @@ class RightMouseNavigationPreferences(AddonPreferences):
5454
def draw(self, context):
5555
layout = self.layout
5656

57-
box = layout.box()
58-
box.label(text="Menu / Movement", icon="DRIVER_DISTANCE")
59-
box.prop(self, "time")
60-
6157
row = layout.row()
6258
box = row.box()
63-
box.label(text="Cursor", icon="ORIENTATION_CURSOR")
64-
box.prop(self, "reset_cursor_on_exit")
59+
box.label(text="Menu / Movement", icon="DRIVER_DISTANCE")
60+
box.prop(self, "time")
6561
box = row.box()
6662
box.label(text="Node Editor", icon="NODETREE")
6763
box.prop(self, "enable_for_node_editors")
6864

6965
row = layout.row()
7066
box = row.box()
67+
box.label(text="Cursor", icon="ORIENTATION_CURSOR")
68+
box.prop(self, "reset_cursor_on_exit")
69+
box = row.box()
7170
box.label(text="View", icon="VIEW3D")
7271
box.prop(self, "return_to_ortho_on_exit")
72+
73+
# Keymap Customization
74+
import rna_keymap_ui
75+
76+
wm = bpy.context.window_manager
77+
active_kc = wm.keyconfigs.active
78+
79+
addon_keymaps = []
80+
81+
walk_km = active_kc.keymaps["View3D Walk Modal"]
82+
83+
for key in walk_km.keymap_items:
84+
addon_keymaps.append((walk_km, key))
85+
86+
header, panel = layout.panel(idname="keymap", default_closed=True)
87+
header.label(text="Navigation Keymap")
88+
89+
wm = bpy.context.window_manager
90+
kc = wm.keyconfigs.user
91+
old_km_name = ""
92+
get_kmi_l = []
93+
for km_add, kmi_add in addon_keymaps:
94+
for km_con in kc.keymaps:
95+
if km_add.name == km_con.name:
96+
km = km_con
97+
break
98+
99+
for kmi_con in km.keymap_items:
100+
if kmi_add.idname == kmi_con.idname:
101+
if kmi_add.name == kmi_con.name:
102+
get_kmi_l.append((km, kmi_con))
103+
104+
get_kmi_l = sorted(set(get_kmi_l), key=get_kmi_l.index)
105+
106+
if panel:
107+
col = panel.column(align=True)
108+
for km, kmi in get_kmi_l:
109+
if not km.name == old_km_name:
110+
col.label(text=str(km.name), icon="DOT")
111+
col.context_pointer_set("keymap", km)
112+
rna_keymap_ui.draw_kmi([], kc, km, kmi, col, 0)
113+
col.separator()
114+
old_km_name = km.name

__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def register():
2121
kmi2 = km2.keymap_items.new("rmn.right_mouse_navigation", "RIGHTMOUSE", "PRESS")
2222
kmi2.active = False
2323

24-
addon_keymaps.append((km, kmi, km2, kmi2))
24+
addon_keymaps.append((km, kmi))
25+
addon_keymaps.append((km2, kmi2))
2526

2627
active_kc = wm.keyconfigs.active
2728

blender_manifest.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
schema_version = "1.0.0"
22

33
id = "right_mouse_navigation"
4-
version = "2.4.0"
4+
version = "2.5.0"
55
name = "Right Mouse Navigation"
6-
tagline = "Game Engine-style Viewport & Node Navigation"
6+
tagline = "Game Engine Movement and Menus"
77
maintainer = "Spectral Vectors and Contributors"
88
type = "add-on"
99

0 commit comments

Comments
 (0)