Created GuiOutsideClickableElement interface for GuiElements that can be deselected/closed by clicking outside of them and properly forward mouse clicks to these elements

This commit is contained in:
CrushedPixel
2015-07-19 14:42:12 +02:00
parent 7a7766c20f
commit d6c03644b8
6 changed files with 19 additions and 6 deletions

View File

@@ -66,8 +66,13 @@ public class ComposedElement implements GuiElement {
boolean clicked = false;
//iterate over elements in reverse order to first handle mouse clicks of elements that are drawn on top
for (int i=0; i<parts.size(); i++) {
clicked = parts.get(parts.size()-1-i).mouseClick(mc, mouseX, mouseY, button);
if(clicked) break;
GuiElement part = parts.get(parts.size() - 1 - i);
//if GuiOutsideClickableElement, forward mouse clicks outside of that element
if(!clicked || (part instanceof GuiOutsideClickableElement && !part.isHovering(mouseX, mouseY))) {
boolean cl = part.mouseClick(mc, mouseX, mouseY, button);
if(cl) clicked = cl;
}
}
return clicked;
}