Reimplemented "MouseEvent" as RawMouseEvent for 1.14.X (#6144)

This commit is contained in:
MrCrayfish authored and LexManos committed 2019-09-16 13:03:10 -07:00
1 parent 60eecb98a6
commit f4215d121c
3 files changed
+72 -7

No files matched your search

@@ -1038,4 +1038,9 @@ public class ForgeHooksClient
Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftDown(), mouseHelper.isMiddleDown(), mouseHelper.isRightDown(), mouseHelper.getMouseX(), mouseHelper.getMouseY());
return MinecraftForge.EVENT_BUS.post(event);
}
public static boolean onRawMouseClicked(int button, int action, int mods)
{
return MinecraftForge.EVENT_BUS.post(new InputEvent.RawMouseEvent(button, action, mods));
}
}
@@ -27,6 +27,59 @@ import org.lwjgl.glfw.GLFW;
public class InputEvent extends Event
{
/**
* A cancellable mouse event fired before key bindings are updated
*/
public static class RawMouseEvent extends InputEvent
{
private final int button;
private final int action;
private final int mods;
public RawMouseEvent(int button, int action, int mods)
{
this.button = button;
this.action = action;
this.mods = mods;
}
/**
* The mouse button that triggered this event.
* https://www.glfw.org/docs/latest/group__buttons.html
*
* @see GLFW mouse constants starting with "GLFW_MOUSE_BUTTON_"
*/
public int getButton()
{
return this.button;
}
/**
* Integer representing the mouse button's action.
*
* @see GLFW#GLFW_PRESS
* @see GLFW#GLFW_RELEASE
*/
public int getAction()
{
return this.action;
}
/**
* Bit field representing the modifier keys pressed.
* https://www.glfw.org/docs/latest/group__mods.html
*
* @see GLFW#GLFW_MOD_SHIFT
* @see GLFW#GLFW_MOD_CONTROL
* @see GLFW#GLFW_MOD_ALT
* @see GLFW#GLFW_MOD_SUPER
*/
public int getMods()
{
return this.mods;
}
}
/**
* This event fires when a mouse input is detected.
*/