Skip to content

Commit

Permalink
Don't show submenu shortcuts for command options
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vlaaad committed Mar 29, 2023
1 parent 9257a31 commit 80133ac
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions editor/src/clj/editor/ui.clj
Expand Up @@ -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))))
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 80133ac

Please sign in to comment.