Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-09-16 16:20:57 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-09-17 09:52:33 +0300
commit06ac655b8dda53aa2122844d487ed68510211395 (patch)
tree6fcd428f6482f83023e75348303ed27592203838 /release
parent6dca61b91c3178a22e8d6e9cdaaeaa12554ffb73 (diff)
WM: expose the "any" state of KeyMapItem modifiers
Change KeyMapItem.alt/ctrl/shift/oskey to integer types, where -1 is used to ignore the modifier when matching key-map items. It was only possible to set all modifiers to -1 at once from RNA using the 'any' property. Afterwards individual modifiers could be set back to true/false. Although these key-map items could not be exported/imported. Exposing the values directly avoids the need for cumbersome workarounds.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/bl_keymap_utils/io.py15
-rw-r--r--release/scripts/modules/rna_keymap_ui.py10
2 files changed, 11 insertions, 14 deletions
diff --git a/release/scripts/modules/bl_keymap_utils/io.py b/release/scripts/modules/bl_keymap_utils/io.py
index 96832cbd9c7..d8b68822feb 100644
--- a/release/scripts/modules/bl_keymap_utils/io.py
+++ b/release/scripts/modules/bl_keymap_utils/io.py
@@ -63,16 +63,11 @@ def kmi_args_as_data(kmi):
if kmi.any:
s.append("\"any\": True")
else:
- if kmi.shift:
- s.append("\"shift\": True")
- if kmi.ctrl:
- s.append("\"ctrl\": True")
- if kmi.alt:
- s.append("\"alt\": True")
- if kmi.oskey:
- s.append("\"oskey\": True")
- if kmi.key_modifier and kmi.key_modifier != 'NONE':
- s.append(f"\"key_modifier\": '{kmi.key_modifier}'")
+ for attr in ("shift", "ctrl", "alt", "oskey"):
+ if mod := getattr(kmi, attr):
+ s.append(f"\"{attr:s}\": " + ("-1" if mod == -1 else "True"))
+ if (mod := kmi.key_modifier) and (mod != 'NONE'):
+ s.append(f"\"key_modifier\": '{mod:s}'")
if kmi.repeat:
if (
diff --git a/release/scripts/modules/rna_keymap_ui.py b/release/scripts/modules/rna_keymap_ui.py
index b42539ac44a..08035d25481 100644
--- a/release/scripts/modules/rna_keymap_ui.py
+++ b/release/scripts/modules/rna_keymap_ui.py
@@ -199,10 +199,12 @@ def draw_kmi(display_keymaps, kc, km, kmi, layout, level):
subrow = sub.row()
subrow.scale_x = 0.75
subrow.prop(kmi, "any", toggle=True)
- subrow.prop(kmi, "shift", toggle=True)
- subrow.prop(kmi, "ctrl", toggle=True)
- subrow.prop(kmi, "alt", toggle=True)
- subrow.prop(kmi, "oskey", text="Cmd", toggle=True)
+ # Use `*_ui` properties as integers aren't practical.
+ subrow.prop(kmi, "shift_ui", toggle=True)
+ subrow.prop(kmi, "ctrl_ui", toggle=True)
+ subrow.prop(kmi, "alt_ui", toggle=True)
+ subrow.prop(kmi, "oskey_ui", text="Cmd", toggle=True)
+
subrow.prop(kmi, "key_modifier", text="", event=True)
# Operator properties