client: Add configurable hotkey to toggle plugin panel

This commit is contained in:
loldudester
2020-01-26 22:15:25 +00:00
committed by Jordan Atwood
parent 7784395255
commit 15e0f1e5f2
2 changed files with 42 additions and 0 deletions

View File

@@ -312,4 +312,15 @@ public interface RuneLiteConfig extends Config
{
return new Keybind(KeyEvent.VK_F11, InputEvent.CTRL_DOWN_MASK);
}
@ConfigItem(
keyName = "panelToggleKey",
name = "Plugin Panel Toggle Key",
description = "The key that will toggle the current or last opened plugin panel (accepts modifiers)",
position = 45
)
default Keybind panelToggleKey()
{
return new Keybind(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK);
}
}

View File

@@ -353,6 +353,17 @@ public class ClientUI
keyManager.registerKeyListener(sidebarListener);
final HotkeyListener pluginPanelListener = new HotkeyListener(config::panelToggleKey)
{
@Override
public void hotkeyPressed()
{
togglePluginPanel();
}
};
keyManager.registerKeyListener(pluginPanelListener);
// Add mouse listener
final MouseListener mouseListener = new MouseAdapter()
{
@@ -738,6 +749,26 @@ public class ClientUI
}
}
private void togglePluginPanel()
{
// Toggle plugin panel open
final boolean pluginPanelOpen = pluginPanel != null;
if (currentButton != null)
{
currentButton.setSelected(!pluginPanelOpen);
}
if (pluginPanelOpen)
{
contract();
}
else
{
expand(currentNavButton);
}
}
private void expand(@Nullable NavigationButton button)
{
if (button == null)