Skip to content

Commit

Permalink
Application: Show toolbar action keystrokes in their tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadelessFox committed Mar 1, 2024
1 parent 5f8f9d8 commit 26950f0
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 26950f0

Please sign in to comment.