chatcommands: Make chat clearing keybinds configurable (#10308)
Closes #6929
This commit is contained in:
@@ -27,6 +27,9 @@ package net.runelite.client.plugins.chatcommands;
|
|||||||
import net.runelite.client.config.Config;
|
import net.runelite.client.config.Config;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
|
import net.runelite.client.config.Keybind;
|
||||||
|
import java.awt.event.InputEvent;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
@ConfigGroup("chatcommands")
|
@ConfigGroup("chatcommands")
|
||||||
public interface ChatCommandsConfig extends Config
|
public interface ChatCommandsConfig extends Config
|
||||||
@@ -121,12 +124,23 @@ public interface ChatCommandsConfig extends Config
|
|||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 8,
|
position = 8,
|
||||||
keyName = "clearShortcuts",
|
keyName = "clearSingleWord",
|
||||||
name = "Clear shortcuts",
|
name = "Clear Single Word",
|
||||||
description = "Enable shortcuts (ctrl+w and backspace) for clearing the chatbox"
|
description = "Enable hot key to clear single word at a time"
|
||||||
)
|
)
|
||||||
default boolean clearShortcuts()
|
default Keybind clearSingleWord()
|
||||||
{
|
{
|
||||||
return true;
|
return new Keybind(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 9,
|
||||||
|
keyName = "clearEntireChatBox",
|
||||||
|
name = "Clear Chat Box",
|
||||||
|
description = "Enable hotkey to clear entire chat box"
|
||||||
|
)
|
||||||
|
default Keybind clearChatBox()
|
||||||
|
{
|
||||||
|
return new Keybind(KeyEvent.VK_BACK_SPACE, InputEvent.CTRL_DOWN_MASK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,14 +54,8 @@ public class ChatKeyboardListener implements KeyListener
|
|||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent e)
|
public void keyPressed(KeyEvent e)
|
||||||
{
|
{
|
||||||
if (!e.isControlDown() || !chatCommandsConfig.clearShortcuts())
|
if (chatCommandsConfig.clearSingleWord().matches(e))
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (e.getKeyCode())
|
|
||||||
{
|
|
||||||
case KeyEvent.VK_W:
|
|
||||||
String input = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
|
String input = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
|
||||||
if (input != null)
|
if (input != null)
|
||||||
{
|
{
|
||||||
@@ -89,14 +83,14 @@ public class ChatKeyboardListener implements KeyListener
|
|||||||
client.runScript(ScriptID.CHAT_PROMPT_INIT);
|
client.runScript(ScriptID.CHAT_PROMPT_INIT);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case KeyEvent.VK_BACK_SPACE:
|
else if (chatCommandsConfig.clearChatBox().matches(e))
|
||||||
|
{
|
||||||
clientThread.invoke(() ->
|
clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
|
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
|
||||||
client.runScript(ScriptID.CHAT_PROMPT_INIT);
|
client.runScript(ScriptID.CHAT_PROMPT_INIT);
|
||||||
});
|
});
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user