From 80133aca5ffa217d7cd0065c10866a9f3eeed7d8 Mon Sep 17 00:00:00 2001 From: Vlad Protsenko Date: Wed, 29 Mar 2023 14:38:08 +0200 Subject: [PATCH] Don't show submenu shortcuts for command options User-facing changes: Previously, sub-menus like `File -> New` and `Game Object -> Add Component` showed the same shortcut on every option item. This changeset turns this behavior off. Technical notes: I implemented the fix by only showing the key combo if the menu item does not define custom user data since this is what differentiates the options from each other. It was wrong to show the key combinations on such options because invoking a command using a key combination does not supply this user data anyway. Fixes #7442 --- editor/src/clj/editor/ui.clj | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/editor/src/clj/editor/ui.clj b/editor/src/clj/editor/ui.clj index 5d1c6b7d0a6..02ab9952b84 100644 --- a/editor/src/clj/editor/ui.clj +++ b/editor/src/clj/editor/ui.clj @@ -1258,7 +1258,7 @@ (user-data! menu-item ::menu-item-id id) (when command (.setId menu-item (name command))) - (when (some? key-combo) + (when (and (some? key-combo) (nil? user-data)) (.setAccelerator menu-item key-combo)) (when icon (.setGraphic menu-item (wrap-menu-image (icons/get-image-view icon 16)))) @@ -1310,14 +1310,16 @@ enabled? (handler/enabled? handler-ctx evaluation-context) acc (command->shortcut command)] (if-let [options (handler/options handler-ctx)] - (if (and acc (not (:expand? item))) - (make-menu-command scene id label icon style-classes acc user-data command enabled? check) - (make-submenu id - label - icon - style-classes - (make-menu-items scene options command-contexts command->shortcut evaluation-context) - on-open)) + (do #_(tap> {:command command + :options options}) + (if (and acc (not (:expand? item))) + (make-menu-command scene id label icon style-classes acc user-data command enabled? check) + (make-submenu id + label + icon + style-classes + (make-menu-items scene options command-contexts command->shortcut evaluation-context) + on-open))) (make-menu-command scene id label icon style-classes acc user-data command enabled? check))))))))) (defn- make-menu-items [^Scene scene menu command-contexts command->shortcut evaluation-context]