Class KeybindingsManager
- java.lang.Object
-
- com.realtime.crossfire.jxclient.gui.keybindings.KeybindingsManager
-
public class KeybindingsManager extends java.lang.ObjectManages key bindings.
-
-
Constructor Summary
Constructors Constructor Description KeybindingsManager(@NotNull java.nio.file.Path keybindingsFileVersion2, @NotNull java.nio.file.Path keybindingsFileVersion1, @NotNull GUICommandFactory guiCommandFactory)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancreateKeyBinding(boolean perCharacter, @NotNull CommandList cmdList)Starts creating a new key binding.booleanescPressed()Processes a pressed ESC key.java.lang.Iterable<KeyBinding>getBindingsForPartialCommand(@NotNull java.lang.String command, boolean startOnly)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.booleankeyReleased()Processes a key released event.voidloadKeybindings()Loads the key bindings from the backing file.voidloadPerCharacterBindings(@NotNull java.lang.CharSequence hostname, @NotNull java.lang.CharSequence character)Loads the per-character key bindings.booleanremoveKeyBinding(boolean perCharacter)Starts to remove a key binding.voidsaveKeybindings()Saves the key bindings to the backing file.voidunloadPerCharacterBindings()Unloads (clears and saves) the per-character key bindings.booleanwindowClosing()Should be called when the main window is closing.
-
-
-
Constructor Detail
-
KeybindingsManager
public KeybindingsManager(@NotNull @NotNull java.nio.file.Path keybindingsFileVersion2, @NotNull @NotNull java.nio.file.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 Detail
-
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
public boolean createKeyBinding(boolean perCharacter, @NotNull @NotNull CommandList cmdList)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 java.lang.CharSequence hostname, @NotNull @NotNull java.lang.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.
-
saveKeybindings
public void saveKeybindings()
Saves the key bindings to the backing file.
-
loadKeybindings
public void loadKeybindings()
Loads the key bindings from the backing file.
-
keyReleased
public boolean keyReleased()
Processes a key released event.- Returns:
- whether the event has been consumed
-
keyPressed
public boolean keyPressed(@NotNull @NotNull KeyEvent2 keyEvent)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
public boolean handleKeyPress(@NotNull @NotNull KeyEvent2 e)Processes a key pressed event.- Parameters:
e- the key event- Returns:
- whether the event has been consumed
-
getBindingsForPartialCommand
public java.lang.Iterable<KeyBinding> getBindingsForPartialCommand(@NotNull @NotNull java.lang.String command, boolean startOnly)
Searches bindings having a command text starting with the specified value.- Parameters:
command- the text to search forstartOnly- if true only search the text at the start of the command, else anywhere.- Returns:
- the matching bindings
-
-