use of net.minecraft.client.gui.IGuiEventListener in project iChunUtil by iChun.
the class Fragment method unfocus.
public // pass the unfocused event down. Unfocus triggers before focus is set
void unfocus(// pass the unfocused event down. Unfocus triggers before focus is set
@Nullable IGuiEventListener guiReplacing) {
IGuiEventListener lastFocused = getListener();
if (lastFocused instanceof Fragment && guiReplacing != lastFocused) {
((Fragment<?>) lastFocused).unfocus(guiReplacing);
// set focus to nothing. MouseClicked will handle the focus of the new object.
setListener(null);
}
}
use of net.minecraft.client.gui.IGuiEventListener in project iChunUtil by iChun.
the class Fragment method setListener.
@Override
public void setListener(@Nullable IGuiEventListener iGuiEventListener) {
IGuiEventListener lastFocused = getListener();
if (lastFocused instanceof Fragment && iGuiEventListener != lastFocused) {
((Fragment<?>) lastFocused).unfocus(iGuiEventListener);
}
focused = iGuiEventListener;
}
use of net.minecraft.client.gui.IGuiEventListener in project iChunUtil by iChun.
the class Workspace method setListener.
@Override
public void setListener(@Nullable IGuiEventListener gui) {
IGuiEventListener lastFocused = getListener();
if (lastFocused instanceof Fragment && gui != lastFocused) {
((Fragment<?>) lastFocused).unfocus(gui);
}
if (gui instanceof Window) {
bringToFront((Window<?>) gui);
}
super.setListener(gui);
}
use of net.minecraft.client.gui.IGuiEventListener in project iChunUtil by iChun.
the class ElementFertile method getMinHeight.
@Override
public int getMinHeight() {
int min = 0;
for (IGuiEventListener child : getEventListeners()) {
if (child instanceof Fragment<?>) {
Fragment<?> fragment = (Fragment<?>) child;
int fragHeight = getConstraintSensitiveMinHeight(fragment);
if (fragHeight > min) {
min = fragHeight;
}
}
}
return min > 0 ? min + (getBorderSize() * 2) : 4;
}
use of net.minecraft.client.gui.IGuiEventListener in project Mekanism by mekanism.
the class GhostIngredientHandler method getTargets.
private <INGREDIENT> List<TargetInfo<INGREDIENT>> getTargets(List<? extends IGuiEventListener> children, INGREDIENT ingredient) {
List<TargetInfo<INGREDIENT>> ghostTargets = new ArrayList<>();
for (IGuiEventListener child : children) {
if (child instanceof Widget) {
Widget widget = (Widget) child;
if (widget.visible) {
if (widget instanceof GuiElement) {
// Start by adding any grandchild ghost targets we have as they are the "top" layer, and we want them
// to get checked/interacted with first
ghostTargets.addAll(getTargets(((GuiElement) widget).children(), ingredient));
}
// Then go ahead and check if our element is a ghost target and if it is, and it supports the ingredient add it
if (widget instanceof IJEIGhostTarget) {
IJEIGhostTarget ghostTarget = (IJEIGhostTarget) widget;
IGhostIngredientConsumer ghostHandler = ghostTarget.getGhostHandler();
if (ghostHandler != null && ghostHandler.supportsIngredient(ingredient)) {
ghostTargets.add(new TargetInfo<>(ghostTarget, ghostHandler, widget.x, widget.y, widget.getWidth(), widget.getHeight()));
}
}
}
}
}
return ghostTargets;
}
Aggregations