UI: correct the keymap editor to match the OSKEY label to the platform

This commit is contained in:
Campbell Barton
2025-03-28 13:26:09 +11:00
parent 46bfd3196d
commit 894dca7f76
2 changed files with 14 additions and 1 deletions

View File

@@ -175,6 +175,8 @@ def draw_kmi(display_keymaps, kc, km, kmi, layout, level):
sub.prop(kmi, "idname", text="")
if map_type not in {'TEXTINPUT', 'TIMER'}:
from sys import platform
sub = split.column()
subrow = sub.row(align=True)
@@ -195,11 +197,21 @@ def draw_kmi(display_keymaps, kc, km, kmi, layout, level):
subrow = sub.row()
subrow.scale_x = 0.75
subrow.prop(kmi, "any", toggle=True)
# Match text in `WM_key_event_string`.
match platform:
case "darwin":
oskey_label = "Cmd"
case "win32":
oskey_label = "Win"
case _:
oskey_label = "OS"
# 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, "oskey_ui", text=oskey_label, toggle=True)
# On systems that don't support Hyper, only show if it's enabled.
# Otherwise the user may have a key binding that doesn't work and can't be changed.