HotkeyButton: allow binding the space key

This commit is contained in:
Max Weber
2020-05-24 09:50:59 -06:00
committed by Adam
parent ba9ffb1d60
commit a54374e931

View File

@@ -26,6 +26,8 @@ package net.runelite.client.plugins.config;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import lombok.Getter;
import net.runelite.client.config.Keybind;
@@ -39,10 +41,16 @@ class HotkeyButton extends JButton
public HotkeyButton(Keybind value, boolean modifierless)
{
setValue(value);
addActionListener(e ->
addMouseListener(new MouseAdapter()
{
setValue(Keybind.NOT_SET);
@Override
public void mouseReleased(MouseEvent e)
{
// We have to use a mouse adapter instead of an action listener so the press action key (space) can be bound
setValue(Keybind.NOT_SET);
}
});
addKeyListener(new KeyAdapter()
{
@Override