generated from QuiltMC/quilt-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only send button click event if it used the primary button
- Loading branch information
Showing
14 changed files
with
55 additions
and
16 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
kitten-heart/src/main/java/net/pixaurora/kitten_cube/impl/ui/controls/MouseButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package net.pixaurora.kitten_cube.impl.ui.controls; | ||
|
||
import net.pixaurora.kitten_heart.impl.KitTunes; | ||
|
||
public enum MouseButton { | ||
PRIMARY(0), | ||
SECONDARY(1), | ||
MIDDLE(2); | ||
|
||
private final int defaultOpenglCode; | ||
|
||
private MouseButton(int defaultOpenglCode) { | ||
this.defaultOpenglCode = defaultOpenglCode; | ||
} | ||
|
||
public static MouseButton fromGlfwCode(int buttonCode) { | ||
for (MouseButton button : MouseButton.values()) { | ||
if (button.defaultOpenglCode == buttonCode) { | ||
return button; | ||
} | ||
} | ||
|
||
KitTunes.LOGGER.error("Unrecognized button code on click: `" + buttonCode + "`! Defaulting to PRIMARY"); | ||
return MouseButton.PRIMARY; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...eart/src/main/java/net/pixaurora/kitten_cube/impl/ui/widget/surface/ClickableSurface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package net.pixaurora.kitten_cube.impl.ui.widget.surface; | ||
|
||
import net.pixaurora.kitten_cube.impl.math.Point; | ||
import net.pixaurora.kitten_cube.impl.ui.controls.MouseButton; | ||
|
||
public interface ClickableSurface extends WidgetSurface { | ||
public void onClick(Point mousePos); | ||
public void onClick(Point mousePos, MouseButton button); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters