UI: hide shortcut from gizmo tip when none found

This commit is contained in:
Campbell Barton 2018-11-22 12:18:23 +11:00
parent fb8aa611d0
commit 3e625a7a06
Notes: blender-bot 2023-02-14 05:37:19 +01:00
Referenced by issue #57992, Tooltips: Hide Shortcut if None found
1 changed files with 7 additions and 9 deletions

View File

@ -897,22 +897,20 @@ static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *gz)
/* Shortcut */
{
bool found = false;
IDProperty *prop = gzop->ptr.data;
char buf[128];
if (WM_key_event_operator_string(
C, gzop->type->idname, WM_OP_INVOKE_DEFAULT, prop, true,
buf, ARRAY_SIZE(buf)))
{
found = true;
uiTooltipField *field = text_field_add(
data, &(uiTooltipFormat){
.style = UI_TIP_STYLE_NORMAL,
.color_id = UI_TIP_LC_VALUE,
.is_pad = true,
});
field->text = BLI_sprintfN(TIP_("Shortcut: %s"), buf);
}
uiTooltipField *field = text_field_add(
data, &(uiTooltipFormat){
.style = UI_TIP_STYLE_NORMAL,
.color_id = UI_TIP_LC_VALUE,
.is_pad = true,
});
field->text = BLI_sprintfN(TIP_("Shortcut: %s"), found ? buf : "None");
}
}
}