GuiElement interface's mouseClick method returns a boolean which is handled by ComposedElement to prevent mouse clicks on multiple elements at once

ComposedElement's entries are sorted so that GuiDropdown are always drawn on top
Modified thrown UnsupportedOperationExceptions in CustomImageObject to not be thrown if asset is null
This commit is contained in:
CrushedPixel
2015-07-10 14:26:44 +02:00
parent 8aec0a364a
commit a218c13b44
17 changed files with 135 additions and 55 deletions

View File

@@ -133,11 +133,10 @@ public class GuiDropdown<T extends GuiEntryListEntry> extends GuiAdvancedTextFie
}
@Override
public void mouseClicked(int xPos, int yPos, int mouseButton) {
mouseClickedResult(xPos, yPos);
public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
return mouseClickedResult(mouseX, mouseY);
}
public boolean mouseClickedResult(int xPos, int yPos) {
boolean success = false;
if(!isEnabled) return success;
@@ -202,9 +201,18 @@ public class GuiDropdown<T extends GuiEntryListEntry> extends GuiAdvancedTextFie
}
public void setSelectionIndex(int index) {
setSelectionIndexQuietly(index);
fireSelectionChangeEvent();
}
/**
* Sets the selection index without notifying SelectionChangeListeners.
* @param index The Selection Index
*/
public void setSelectionIndexQuietly(int index) {
this.selectionIndex = index;
if(selectionIndex < 0) selectionIndex = -1;
fireSelectionChangeEvent();
if(selectionIndex >= elements.size()) selectionIndex = elements.size()-1;
}
private void fireSelectionChangeEvent() {