Skip to content

Commit

Permalink
add mouse wheel scrolling for channel data
Browse files Browse the repository at this point in the history
Signed-off-by: Glease <[email protected]>
  • Loading branch information
Glease committed Dec 14, 2024
1 parent 27be10d commit 361d293
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,27 @@ private List<GuiButton> getButtonList() {
return buttonList;
}

private boolean isMouseOverValue() {
int mx = Mouse.getEventX() * this.width / this.mc.displayWidth;
int my = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
return mx >= value.xPosition && mx < value.xPosition + value.width && my >= value.yPosition && my < value.yPosition + value.height;

}

@Override
public void handleMouseInput() {
int delta = Mouse.getEventDWheel();
if (delta != 0) list.handleDWheel(delta);
if (delta != 0) {
if (isMouseOverValue()) {
if (delta > 0) {
value.setText(String.valueOf(getValue() + 1));
} else {
value.setText(String.valueOf(Math.max(getValue() - 1, 1)));
}
} else {
list.handleDWheel(delta);
}
}
super.handleMouseInput();
}

Expand Down

0 comments on commit 361d293

Please sign in to comment.