Clickable and Draggable now also return booleans for whether they handled the event
This commit is contained in:
@@ -42,7 +42,7 @@ public abstract class AbstractGuiClickable<T extends AbstractGuiClickable<T>> ex
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClick(ReadablePoint position, int button) {
|
||||
public boolean mouseClick(ReadablePoint position, int button) {
|
||||
Point pos = new Point(position);
|
||||
if (getContainer() != null) {
|
||||
getContainer().convertFor(this, pos);
|
||||
@@ -50,7 +50,9 @@ public abstract class AbstractGuiClickable<T extends AbstractGuiClickable<T>> ex
|
||||
|
||||
if (isMouseHovering(pos) && isEnabled()) {
|
||||
onClick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isMouseHovering(ReadablePoint pos) {
|
||||
|
||||
@@ -92,8 +92,9 @@ public abstract class AbstractGuiTextField<T extends AbstractGuiTextField<T>>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClick(ReadablePoint position, int button) {
|
||||
public boolean mouseClick(ReadablePoint position, int button) {
|
||||
wrapped.mouseClicked(position.getX(), position.getY(), button);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -394,7 +394,7 @@ public abstract class AbstractGuiTextArea<T extends AbstractGuiTextArea<T>>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClick(ReadablePoint position, int button) {
|
||||
public boolean mouseClick(ReadablePoint position, int button) {
|
||||
if (getContainer() != null) {
|
||||
getContainer().convertFor(this, (Point) (position = new Point(position)));
|
||||
}
|
||||
@@ -414,6 +414,7 @@ public abstract class AbstractGuiTextArea<T extends AbstractGuiTextArea<T>>
|
||||
}
|
||||
|
||||
setFocused(hovering);
|
||||
return hovering;
|
||||
}
|
||||
|
||||
protected boolean isMouseHovering(ReadablePoint pos) {
|
||||
|
||||
@@ -25,5 +25,5 @@ package de.johni0702.minecraft.gui.function;
|
||||
import org.lwjgl.util.ReadablePoint;
|
||||
|
||||
public interface Clickable {
|
||||
void mouseClick(ReadablePoint position, int button);
|
||||
boolean mouseClick(ReadablePoint position, int button);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ package de.johni0702.minecraft.gui.function;
|
||||
import org.lwjgl.util.ReadablePoint;
|
||||
|
||||
public interface Draggable extends Clickable {
|
||||
void mouseDrag(ReadablePoint position, int button, long timeSinceLastCall);
|
||||
void mouseRelease(ReadablePoint position, int button);
|
||||
boolean mouseDrag(ReadablePoint position, int button, long timeSinceLastCall);
|
||||
boolean mouseRelease(ReadablePoint position, int button);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user