Skip to content

Commit 763e923

Browse files
committed
InputMode: add the bindLocal() method
1 parent 8d16d68 commit 763e923

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ui/src/main/java/jme3utilities/ui/InputMode.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,25 @@ public void bind(String actionName, String usHotkeyName) {
254254
addActionName(actionName);
255255
}
256256

257+
/**
258+
* Bind the named action to the named hotkey, but don't map it yet. Any
259+
* existing binding for the hotkey is removed.
260+
*
261+
* @param actionName the name of the action (not null)
262+
* @param localHotkeyName the hotkey's local name (not null)
263+
*/
264+
public void bindLocal(String actionName, String localHotkeyName) {
265+
Validate.nonNull(actionName, "action name");
266+
Validate.nonNull(localHotkeyName, "local hotkey name");
267+
boolean hotkeyExists = (Hotkey.findLocal(localHotkeyName) != null);
268+
Validate.require(hotkeyExists, "the local name of a hotkey");
269+
270+
Hotkey hotkey = Hotkey.findLocal(localHotkeyName);
271+
String usHotkeyName = hotkey.usName();
272+
hotkeyBindings.put(usHotkeyName, actionName);
273+
addActionName(actionName);
274+
}
275+
257276
/**
258277
* Test whether this input mode binds the specified hotkey.
259278
*

0 commit comments

Comments
 (0)