diff --git a/nifty/src/main/java/jme3utilities/nifty/bind/BindScreen.java b/nifty/src/main/java/jme3utilities/nifty/bind/BindScreen.java index 816222bfa..284b1ad0a 100644 --- a/nifty/src/main/java/jme3utilities/nifty/bind/BindScreen.java +++ b/nifty/src/main/java/jme3utilities/nifty/bind/BindScreen.java @@ -344,7 +344,28 @@ private void bindSelected() { } /** - * Find the list-box item for the specified universal code. + * Find the list-box item for the specified action. + * + * @param actionName the name of the action to find (not null) + * @return the pre-existing item, or null if none found + */ + private ActionItem findActionItem(String actionName) { + assert actionName != null; + + ListBox actionBox = getActionBox(); + List list = actionBox.getItems(); + for (ActionItem item : list) { + String name = item.getActionName(); + if (actionName.equals(name)) { + return item; + } + } + + return null; + } + + /** + * Find the hotkey list-box item for the specified universal code. * * @param code universal code (≥0) * @return the pre-existing item, or null if none found @@ -490,7 +511,8 @@ private void populateHotkeyBox(boolean boundFlag) { } /** - * Select the hotkey with the specified code. + * Select the hotkey with the specified code. If the hotkey is bound, also + * select the action it's bound to. * * @param code universal code of the hotkey to select (≥0) */ @@ -501,6 +523,14 @@ private void selectHotkey(int code) { ListBox listBox = getHotkeyBox(); listBox.setFocusItem(item); listBox.selectItem(item); + + Hotkey hotkey = item.getHotkey(); + if (subjectMode.binds(hotkey)) { + String actionName = subjectMode.getActionName(hotkey); + ActionItem actionItem = findActionItem(actionName); + ListBox actionBox = getActionBox(); + actionBox.selectItem(actionItem); + } } /**