Page MenuHome

Context menu for button does not display shortcuts with default value of properties
Closed, ResolvedPublic

Description

System Information
Operating system: Darwin-19.4.0-x86_64-i386-64bit 64 Bits
Graphics card: AMD Radeon Pro 455 OpenGL Engine ATI Technologies Inc. 4.1 ATI-3.8.24

Blender Version
Broken: version: 2.90.0 Alpha, branch: master, commit date: 2020-06-05 22:39, hash: rBb74cc23dc478
Worked: never

Short description of error
The context menu for button does not display some keyboard shortcuts, e.g. for "Insert Keyframe" or "Remove Driver".
Relates to the default value of properties.

Event Timeline

For example, if there are menu items:

layout.operator("view3d.localview", text="Toggle Local View").frame_selected = False
layout.operator("view3d.localview", text="Toggle Local View (Frame Selected)").frame_selected = True

These hotkeys will be displayed in the menu:

("view3d.localview", {"type": 'SLASH', "value": 'PRESS'},
 {"properties": [("frame_selected", False)]}),
("view3d.localview", {"type": 'SLASH', "value": 'PRESS', "alt": True},
 {"properties": [("frame_selected", True)]}),

But this one won't be displayed:

("view3d.localview", {"type": 'SLASH', "value": 'PRESS'}, None),
Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Needs Information from User.Jun 16 2020, 4:13 PM

Thansk for the report but I don't understand what the bug is here.
Not all operators have shortcuts by default.

This report does not contain all the requested information, which is required for us to investigate the issue.
It's missing:

  • Exact steps to reproduce the bug.

Guideline for making a good bug report: https://wiki.blender.org/wiki/Process/Bug_Reports

These are default shortcuts.

anim.keyframe_insert_button
anim.keyframe_delete_button
anim.keyframe_clear_button
anim.driver_button_remove
anim.driver_button_remove
anim.keyingset_button_add

They work but are not displayed in the button context menu:

If you explicitly set the parameter "All" to "True" (which is the same as the default value), the shortcuts will be displayed correctly:

This is not really a bug. The operator on the shortcut has different properties than the button, see interface_context_menu.c$579. (In the button the "all" property is set).
This is a property that can be changed in the Redo panel of some editors.

But it seems reasonable in this case to edit the default keymap to match those buttons.

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index bbbe520441c..1f5613c86bb 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -695,9 +695,12 @@ def km_user_interface(_params):
         ("ui.copy_data_path_button", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
          {"properties": [("full_path", True)]}),
         # Keyframes and drivers
-        ("anim.keyframe_insert_button", {"type": 'I', "value": 'PRESS'}, None),
-        ("anim.keyframe_delete_button", {"type": 'I', "value": 'PRESS', "alt": True}, None),
-        ("anim.keyframe_clear_button", {"type": 'I', "value": 'PRESS', "shift": True, "alt": True}, None),
+        ("anim.keyframe_insert_button", {"type": 'I', "value": 'PRESS'},
+         {"properties": [("all", True)]}),
+        ("anim.keyframe_delete_button", {"type": 'I', "value": 'PRESS', "alt": True},
+         {"properties": [("all", True)]}),
+        ("anim.keyframe_clear_button", {"type": 'I', "value": 'PRESS', "shift": True, "alt": True},
+         {"properties": [("all", True)]}),
         ("anim.driver_button_add", {"type": 'D', "value": 'PRESS', "ctrl": True}, None),
         ("anim.driver_button_remove", {"type": 'D', "value": 'PRESS', "ctrl": True, "alt": True}, None),
         ("anim.keyingset_button_add", {"type": 'K', "value": 'PRESS'}, None),

This is something for the Animation team to decide.

Germano Cavalcante (mano-wii) changed the task status from Needs Information from User to Needs Triage.Jun 16 2020, 5:20 PM

I know pretty much nothing about keymaps. What does {"properties": [("all", True)]} do, and how is it different from None? @Julian Eisel (Severin) can you maybe shed some light on this?

As I understand it, None in this field means that no property value is set for the operator of that keyitem.
This means that the last property that is defined will remain the next time you call the operator via the shortcut.
(Some properties can be changed in fields such as the operator's Redo Panel).

But taking a closer look, those operators don't even have Redo Panel. So I don't think there will be any changes in the user's point of view.
If this is the case then there is no problem applying this change just to display the shortcut in the context menu.

(It is not a bug. It's just a small visual inconvenience).