@@ -21,6 +21,12 @@ import com.lambda.event.callback.Cancellable
2121import com.lambda.event.callback.ICancellable
2222import com.lambda.util.Mouse
2323import com.lambda.util.math.Vec2d
24+ import org.lwjgl.glfw.GLFW.GLFW_MOD_ALT
25+ import org.lwjgl.glfw.GLFW.GLFW_MOD_CAPS_LOCK
26+ import org.lwjgl.glfw.GLFW.GLFW_MOD_CONTROL
27+ import org.lwjgl.glfw.GLFW.GLFW_MOD_NUM_LOCK
28+ import org.lwjgl.glfw.GLFW.GLFW_MOD_SHIFT
29+ import org.lwjgl.glfw.GLFW.GLFW_MOD_SUPER
2430
2531sealed class MouseEvent {
2632 /* *
@@ -32,17 +38,32 @@ sealed class MouseEvent {
3238 * @property position The x and y position of the mouse on the screen
3339 */
3440 data class Click (
35- val button : Mouse . Button ,
36- val action : Mouse . Action ,
41+ val button : Int ,
42+ val action : Int ,
3743 val modifiers : Int ,
3844 val position : Vec2d ,
3945 ) : ICancellable by Cancellable() {
40- constructor (button: Int , action: Int , modifiers: Int , position: Vec2d ) : this (
41- Mouse . Button .fromMouseCode( button) ,
42- Mouse . Action .fromActionCode( action) ,
46+ constructor (button: Mouse . Button , action: Mouse . Action , modifiers: Int , position: Vec2d ) : this (
47+ button.ordinal ,
48+ action.ordinal ,
4349 modifiers,
4450 position
4551 )
52+
53+ val isMainButton = button <= 2
54+ val isSideButton = button > 2
55+ val isLeftButton = button == 0
56+ val isRightButton = button == 1
57+ val isMiddleButton = button == 2
58+
59+ val hasShift = hasModifier(GLFW_MOD_SHIFT )
60+ val hasControl = hasModifier(GLFW_MOD_CONTROL )
61+ val hasAlt = hasModifier(GLFW_MOD_ALT )
62+ val hasSuper = hasModifier(GLFW_MOD_SUPER )
63+ val hasCapsLock = hasModifier(GLFW_MOD_CAPS_LOCK )
64+ val hasNumLock = hasModifier(GLFW_MOD_NUM_LOCK )
65+
66+ fun hasModifier (mod : Int ) = modifiers and mod == mod
4667 }
4768
4869 /* *
0 commit comments