Page MenuHome

Fix missing hotkeys in brush icons
ClosedPublic

Authored by Joseph Eagar (joeedh) on Apr 18 2022, 12:24 AM.

Details

Summary

This patch fixes missing hotkeys for brush icons. The paint mode code branch in ui_tooltip_data_from_tool was broken; it was failing to strip the leading "builtin_brush." from the brush path prior to looking up the tool in the tool mode RNA enum. This patch fixes that. Not sure if this is the preferred way to strip leading RNA paths though.

Note there is one code path that shows hotkeys; if you set spacebar mode to "Tools" a wm.toolbar keymap entry will be added. This will trigger another branch in ui_tooltip_data_from_tool, however the resulting hotkeys will have "spacebar" prepended to them (which as far as I can tell is incorrect).

Diff Detail

Event Timeline

The fix seems fine but think it can be written in a simpler way, no need for an extra review pass.

source/blender/editors/interface/interface_region_tooltip.c
530–538

This looks like it could be written in a less verbose way.

/* Step over the prefix such as "builtin_brush.Draw" -> "Draw" for the enum lookup. */
const char *tool_id_lstrip = strrchr(tool_id, '.');
const int tool_id_offset = tool_id_lstrip ? ((tool_id_lstrip - tool_id) + 1) : 0;
const int i = RNA_enum_from_name(items, tool_id + tool_id_offset);

Unless there is a good reason to loop over the string with strcspn, this seems like a more direct way to do the same thing.

This revision is now accepted and ready to land.Apr 28 2022, 1:40 PM