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