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