From 26950f01a8f53c43ad98cf99a286eae7c927e029 Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Fri, 1 Mar 2024 20:21:41 +0100 Subject: [PATCH] Application: Show toolbar action keystrokes in their tooltips --- .../com/shade/platform/ui/menus/impl/MenuManagerImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/platform-ui/src/main/java/com/shade/platform/ui/menus/impl/MenuManagerImpl.java b/modules/platform-ui/src/main/java/com/shade/platform/ui/menus/impl/MenuManagerImpl.java index a1f954a90..66ecd0666 100644 --- a/modules/platform-ui/src/main/java/com/shade/platform/ui/menus/impl/MenuManagerImpl.java +++ b/modules/platform-ui/src/main/java/com/shade/platform/ui/menus/impl/MenuManagerImpl.java @@ -456,9 +456,15 @@ public void update() { } putValue(Action.NAME, Objects.requireNonNullElseGet(item.getName(context), metadata::name)); - putValue(Action.SHORT_DESCRIPTION, metadata.description()); putValue(Action.SMALL_ICON, icon); + if (metadata.keystroke().isEmpty()) { + putValue(Action.SHORT_DESCRIPTION, metadata.description()); + } else { + final String accelerator = UIUtils.getTextForAccelerator(KeyStroke.getKeyStroke(metadata.keystroke())); + putValue(Action.SHORT_DESCRIPTION, "%s (%s)".formatted(metadata.description(), accelerator)); + } + if (item instanceof MenuItem.Check check) { putValue(Action.SELECTED_KEY, check.isChecked(context)); } else if (item instanceof MenuItem.Radio radio) {