Class KeybindingsManager
java.lang.Object
com.realtime.crossfire.jxclient.gui.keybindings.KeybindingsManager
Manages key bindings.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NotNull StringThe source identification string for per-character key bindings.static final @NotNull StringThe source identification string for default key bindings.static final @NotNull StringThe source identification string for global key bindings. -
Constructor Summary
ConstructorsConstructorDescriptionKeybindingsManager(@NotNull Path keybindingsFileVersion2, @NotNull Path keybindingsFileVersion1, @NotNull GUICommandFactory guiCommandFactory) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleancreateKeyBinding(boolean perCharacter, @NotNull CommandList cmdList) Starts creating a new key binding.booleanProcesses a pressed ESC key.@NotNull Map<KeyBinding,String> getBindings(@NotNull Predicate<KeyBinding> predicate) Searches bindings having a command text starting with the specified value.booleanhandleKeyPress(@NotNull KeyEvent2 e) Processes a key pressed event.booleankeyPressed(@NotNull KeyEvent2 keyEvent) Processes a key pressed event.booleanProcesses a key released event.voidLoads the global key bindings from the backing file.voidloadPerCharacterBindings(@NotNull CharSequence hostname, @NotNull CharSequence character) Loads the per-character key bindings.booleanremoveKeyBinding(boolean perCharacter) Starts to remove a key binding.voidSaves the global key bindings to the backing file.voidsetDefaultKeyBindings(@NotNull KeyBindings defaultKeyBindings) Sets the defaultKeyBindingsof the currently active skin.voidUnloads (clears and saves) the per-character key bindings.booleanShould be called when the main window is closing.
-
Field Details
-
DEFAULT
The source identification string for default key bindings.- See Also:
-
GLOBAL
The source identification string for global key bindings.- See Also:
-
CHARACTER
The source identification string for per-character key bindings.- See Also:
-
-
Constructor Details
-
KeybindingsManager
public KeybindingsManager(@NotNull @NotNull Path keybindingsFileVersion2, @NotNull @NotNull Path keybindingsFileVersion1, @NotNull @NotNull GUICommandFactory guiCommandFactory) Creates a new instance.- Parameters:
keybindingsFileVersion2- the global keybindings filekeybindingsFileVersion1- the global fallback keybindings fileguiCommandFactory- the gui command factory for creating commands
-
-
Method Details
-
setDefaultKeyBindings
Sets the defaultKeyBindingsof the currently active skin.- Parameters:
defaultKeyBindings- the default key bindings
-
removeKeyBinding
public boolean removeKeyBinding(boolean perCharacter) Starts to remove a key binding.- Parameters:
perCharacter- whether a per-character key binding should be removed- Returns:
- whether the key bindings dialog should be opened
-
windowClosing
public boolean windowClosing()Should be called when the main window is closing.- Returns:
- whether the key bindings dialog should be closed
-
createKeyBinding
Starts creating a new key binding.- Parameters:
perCharacter- whether a per-character key bindings should be createdcmdList- the commands for the key binding- Returns:
- whether the key bindings dialog should be opened
-
loadPerCharacterBindings
public void loadPerCharacterBindings(@NotNull @NotNull CharSequence hostname, @NotNull @NotNull CharSequence character) Loads the per-character key bindings. This function should be called when a character logs in.- Parameters:
hostname- the character's hostnamecharacter- the character's name
-
unloadPerCharacterBindings
public void unloadPerCharacterBindings()Unloads (clears and saves) the per-character key bindings. This function should be called when a character logs out. -
saveGlobalKeybindings
public void saveGlobalKeybindings()Saves the global key bindings to the backing file. -
loadGlobalKeybindings
public void loadGlobalKeybindings()Loads the global key bindings from the backing file. -
keyReleased
public boolean keyReleased()Processes a key released event.- Returns:
- whether the event has been consumed
-
keyPressed
Processes a key pressed event.- Parameters:
keyEvent- the key event- Returns:
- whether the event has been consumed
-
escPressed
public boolean escPressed()Processes a pressed ESC key.- Returns:
- whether the event has been consumed and the key bindings dialog should be closed
-
handleKeyPress
Processes a key pressed event.- Parameters:
e- the key event- Returns:
- whether the event has been consumed
-
getBindings
@NotNull public @NotNull Map<KeyBinding,String> getBindings(@NotNull @NotNull Predicate<KeyBinding> predicate) Searches bindings having a command text starting with the specified value.- Parameters:
predicate- the predicate for selecting keybindings- Returns:
- the matching bindings; maps key bindings to the source that defines the key binding
-