Skip to content

Avoid consuming scroll event if mouse is in exclusion area#222

Open
ZZZank wants to merge 3 commits into
CleanroomMC:cleanroomfrom
ZZZank:mouse-in-excluded-area
Open

Avoid consuming scroll event if mouse is in exclusion area#222
ZZZank wants to merge 3 commits into
CleanroomMC:cleanroomfrom
ZZZank:mouse-in-excluded-area

Conversation

@ZZZank

@ZZZank ZZZank commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This PR added an additional exclusion area check to avoid consuming scroll event, if the mouse is in exclusion area. Other exclusion area check in IMouseHandler.isMouseOver(int,int) is removed, to 1. keep implementations consistent, and 2. avoid performing the same check multiple times

Should be able to fix some mods having their scrolling handler not working, as long as they declared correct exclusion areas.

@ZZZank ZZZank marked this pull request as draft July 10, 2026 14:40
@ZZZank ZZZank force-pushed the mouse-in-excluded-area branch from ab3ce4a to 330af8f Compare July 11, 2026 09:37
@ZZZank ZZZank changed the title Avoid consuming scroll event if mouse is not actually over GUI element Avoid consuming scroll event if mouse is in exclusion area Jul 11, 2026
@ZZZank ZZZank marked this pull request as ready for review July 11, 2026 11:30
@ZZZank

ZZZank commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

before:

before.mp4

after:

after.mp4

@WaitingIdly WaitingIdly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isMouseOver is used for a number of things, and removing this check means your goal of "not running multiple times" causes other other places to run checks when they shouldnt. should keep/add && !guiScreenHelper.isInGuiExclusionArea(mouseX, mouseY) to relevant isMouseOver checks. this also makes it the same as all of the other similar methods in \w*GridWithNavigation.

@ZZZank ZZZank requested a review from WaitingIdly July 12, 2026 14:01

@WaitingIdly WaitingIdly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont see the need for defense comments about how particular checks arent required.

Comment thread src/main/java/mezz/jei/gui/overlay/IngredientListOverlay.java Outdated
Comment thread src/main/java/mezz/jei/gui/overlay/bookmarks/LeftAreaDispatcher.java Outdated
@ZZZank ZZZank force-pushed the mouse-in-excluded-area branch from 51e1193 to 54767bb Compare July 14, 2026 08:21
@ZZZank

ZZZank commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

This PR is rewritten again for a working implementation with (hopefully) minimum code logic change. The usage of .handleMouseXxxxx() among the entire project is a bit confusing, where isMouseOver(x,y) is not always called before calling it. Eventually I decided to add ,isMouseOver() check at the entrypoint of scroll handling, and leave scroll handling inside scroll handling unchanged.

@WaitingIdly WaitingIdly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think IngredientListOverlay could be neater, but looks good

Comment on lines +223 to +235
boolean result;
if (isListDisplayed()) {
if (Config.isCenterSearchBarEnabled() && searchField.isMouseOver(mouseX, mouseY)) {
return true;
result = true;
} else {
result = displayArea.contains(mouseX, mouseY);
}
return displayArea.contains(mouseX, mouseY);
} else if (this.guiProperties != null) {
return this.configButton.isMouseOver(mouseX, mouseY);
result = this.configButton.isMouseOver(mouseX, mouseY);
} else {
result = false;
}
return false;
return result && !guiScreenHelper.isInGuiExclusionArea(mouseX, mouseY);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always need to check it, might as well do it first.

Suggested change
boolean result;
if (isListDisplayed()) {
if (Config.isCenterSearchBarEnabled() && searchField.isMouseOver(mouseX, mouseY)) {
return true;
result = true;
} else {
result = displayArea.contains(mouseX, mouseY);
}
return displayArea.contains(mouseX, mouseY);
} else if (this.guiProperties != null) {
return this.configButton.isMouseOver(mouseX, mouseY);
result = this.configButton.isMouseOver(mouseX, mouseY);
} else {
result = false;
}
return false;
return result && !guiScreenHelper.isInGuiExclusionArea(mouseX, mouseY);
if (guiScreenHelper.isInGuiExclusionArea(mouseX, mouseY)) {
return false;
}
if (isListDisplayed()) {
if (Config.isCenterSearchBarEnabled() && searchField.isMouseOver(mouseX, mouseY)) {
return true;
}
return displayArea.contains(mouseX, mouseY);
}
if (this.guiProperties != null) {
return this.configButton.isMouseOver(mouseX, mouseY);
}
return false;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The weird code logic here is because when I was writing it, I considered exclusion area check as something expensive and should be done last, just like other usages. But probably it doesn't matter, since it won't be called thousands of times per second?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants