[Fix] Odd scroll/focus interaction
This commit is contained in:
parent
8c0372e4bc
commit
20c89735ce
6 changed files with 25 additions and 16 deletions
|
@ -118,6 +118,7 @@ public abstract class AbstractStack<R extends ComponentRenderer, T extends Abstr
|
|||
focused = guiEventListener;
|
||||
}
|
||||
|
||||
|
||||
public Image addIcon(ResourceLocation location, Size resourceSize) {
|
||||
Image i = new Image(Value.fixed(24), Value.fixed(24), location, resourceSize);
|
||||
add(i);
|
||||
|
@ -222,5 +223,16 @@ public abstract class AbstractStack<R extends ComponentRenderer, T extends Abstr
|
|||
add(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
public ColorPicker addColorPicker(
|
||||
Value width,
|
||||
Value height,
|
||||
net.minecraft.network.chat.Component titleOrNull,
|
||||
int color
|
||||
) {
|
||||
ColorPicker c = new ColorPicker(width, height, titleOrNull, color);
|
||||
add(c);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ public abstract class AbstractVanillaComponent<C extends AbstractWidget, V exten
|
|||
@Override
|
||||
public boolean isMouseOver(double x, double y) {
|
||||
if (vanillaComponent != null && enabled)
|
||||
return vanillaComponent.isMouseOver(x, y);
|
||||
return vanillaComponent.isMouseOver(x - relativeBounds.left, y - relativeBounds.top);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,4 +88,9 @@ public class Input extends AbstractVanillaComponent<EditBox, Input> {
|
|||
public boolean changeFocus(boolean bl) {
|
||||
return super.changeFocus(bl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double x, double y, int button) {
|
||||
return super.mouseClicked(x, y, button);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,15 +100,6 @@ public class Panel implements ComponentWithBounds, RelativeContainerEventHandler
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOver(double x, double y) {
|
||||
if (child != null) {
|
||||
if (child.isMouseOver(x - bounds.left, y - bounds.top))
|
||||
return true;
|
||||
}
|
||||
return bounds.contains(x, y);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void mouseMoved(double x, double y) {
|
||||
// if (child != null)
|
||||
|
|
|
@ -255,13 +255,14 @@ public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRend
|
|||
);
|
||||
}
|
||||
if (!didCapture) {
|
||||
scrollerY = scrollerY + delta;
|
||||
scrollerY = Math.max(0, Math.min(travel, scrollerY)) + delta;
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("Child did capture scroll");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
GuiEventListener focused;
|
||||
|
||||
@Nullable
|
||||
|
@ -283,7 +284,6 @@ public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRend
|
|||
dragging = bl;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isMouseOver(double x, double y) {
|
||||
if (child != null) {
|
||||
|
@ -292,6 +292,4 @@ public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRend
|
|||
}
|
||||
return relativeBounds.contains(x, y);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,10 +16,13 @@ public interface RelativeContainerEventHandler extends ContainerEventHandler {
|
|||
|
||||
default Optional<GuiEventListener> getChildAt(double d, double e) {
|
||||
Rectangle r = getInputBounds();
|
||||
return ContainerEventHandler.super.getChildAt(d - r.left, e - r.top);
|
||||
return ContainerEventHandler.super.getChildAt(d, e);
|
||||
}
|
||||
|
||||
default boolean mouseClicked(double d, double e, int i) {
|
||||
if (getFocused() != null) {
|
||||
getFocused().mouseClicked(d, e, i);
|
||||
}
|
||||
Rectangle r = getInputBounds();
|
||||
return ContainerEventHandler.super.mouseClicked(d - r.left, e - r.top, i);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue