Only poll Mouse Wheel change if hovering over GuiDropdown/GuiEntryList to avoid multiple Elements clashing

This commit is contained in:
CrushedPixel
2015-08-31 17:07:51 +02:00
parent 635e821688
commit e1d307cfcf
2 changed files with 20 additions and 12 deletions

View File

@@ -36,7 +36,7 @@ public class GuiDropdown<T extends GuiEntryListEntry> extends GuiAdvancedTextFie
}
@Override
public void drawTextBox() {
public void draw(Minecraft mc, int mouseX, int mouseY) {
if(elements.size() > selectionIndex && selectionIndex >= 0) {
setText(mc.fontRendererObj.trimStringToWidth(
elements.get(selectionIndex).getDisplayString(), width - 8));
@@ -106,11 +106,15 @@ public class GuiDropdown<T extends GuiEntryListEntry> extends GuiAdvancedTextFie
if(drawScrollBar) {
//The scroll bar
int dw = Mouse.getDWheel();
if(dw > 0) {
dw = -1;
} else if(dw < 0) {
dw = 1;
int dw = 0;
if(isHovering(mouseX, mouseY)) {
dw = Mouse.getDWheel();
if(dw > 0) {
dw = -1;
} else if(dw < 0) {
dw = 1;
}
}
upperIndex = Math.max(Math.min(upperIndex + dw, elements.size() - visibleDropout), 0);

View File

@@ -39,7 +39,7 @@ public class GuiEntryList<T extends GuiEntryListEntry> extends GuiAdvancedTextFi
}
@Override
public void drawTextBox() {
public void draw(Minecraft mc, int mouseX, int mouseY) {
try {
super.drawTextBox();
@@ -68,11 +68,15 @@ public class GuiEntryList<T extends GuiEntryListEntry> extends GuiAdvancedTextFi
//drawing the scroll bar
if(elements.size() > visibleElements) {
//handle scroll events
int dw = Mouse.getDWheel();
if(dw > 0) {
dw = -1;
} else if(dw < 0) {
dw = 1;
int dw = 0;
if(isHovering(mouseX, mouseY)) {
dw = Mouse.getDWheel();
if(dw > 0) {
dw = -1;
} else if(dw < 0) {
dw = 1;
}
}
upperIndex = Math.max(Math.min(upperIndex + dw, elements.size() - visibleElements), 0);