Skip to content

Commit 0058f9c

Browse files
github-actions[bot]vaisestLocalIdentity
authored
[pob2-port] Add option to disable scroll wheel interacting with controls (#9906)
* Apply changes from PathOfBuildingCommunity/PathOfBuilding-PoE2#2176 * Fix merge * More fixes --------- Co-authored-by: vaisest <vaisest@users.noreply.github.com> Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent 52c028a commit 0058f9c

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/Classes/DropDownControl.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ function DropDownClass:OnKeyUp(key)
487487
if self.dropped and self.controls.scrollBar.enabled then
488488
self.controls.scrollBar:Scroll(1)
489489
else
490+
if main.disableScrollControlInteraction and key == "WHEELDOWN" then
491+
return
492+
end
490493
self:SetSel(self:ListIndexToDropIndex(self.selIndex, 0) + 1)
491494
end
492495
return self
@@ -498,6 +501,9 @@ function DropDownClass:OnKeyUp(key)
498501
if self.dropped and self.controls.scrollBar.enabled then
499502
self.controls.scrollBar:Scroll(-1)
500503
else
504+
if main.disableScrollControlInteraction and key == "WHEELUP" then
505+
return
506+
end
501507
self:SetSel(self:ListIndexToDropIndex(self.selIndex, 0) - 1)
502508
end
503509
return self

src/Classes/EditControl.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ function EditClass:OnKeyUp(key)
675675
end
676676
elseif self.isNumeric then
677677
local cur = tonumber(self.buf)
678-
if key == "WHEELUP" or key == "UP" then
678+
if (not main.disableScrollControlInteraction and (key == "WHEELUP")) or key == "UP" then
679679
if cur then
680680
self:SetText(tostring(cur + (self.numberInc or 1)), true)
681681
else
@@ -685,7 +685,7 @@ function EditClass:OnKeyUp(key)
685685
self:SetText("1", true)
686686
end
687687
end
688-
elseif key == "WHEELDOWN" or key == "DOWN" then
688+
elseif (not main.disableScrollControlInteraction and (key == "WHEELDOWN")) or key == "DOWN" then
689689
if cur and (self.filter ~= "%D" or cur > 0)then
690690
self:SetText(tostring(cur - (self.numberInc or 1)), true)
691691
else

src/Modules/Main.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ function main:Init()
118118
self.showFlavourText = true
119119
self.showAnimations = true
120120
self.showAllItemAffixes = true
121+
self.disableScrollControlInteraction = false
121122
self.errorReadingSettings = false
122123

123124
if not SetDPIScaleOverridePercent then SetDPIScaleOverridePercent = function(scale) end end
@@ -626,6 +627,9 @@ function main:LoadSettings(ignoreBuild)
626627
if node.attrib.showAllItemAffixes then
627628
self.showAllItemAffixes = node.attrib.showAllItemAffixes == "true"
628629
end
630+
if node.attrib.disableScrollControlInteraction then
631+
self.disableScrollControlInteraction = node.attrib.disableScrollControlInteraction == "true"
632+
end
629633
if node.attrib.dpiScaleOverridePercent then
630634
self.dpiScaleOverridePercent = tonumber(node.attrib.dpiScaleOverridePercent) or 0
631635
SetDPIScaleOverridePercent(self.dpiScaleOverridePercent)
@@ -760,6 +764,7 @@ function main:SaveSettings()
760764
showFlavourText = tostring(self.showFlavourText),
761765
showAnimations = tostring(self.showAnimations),
762766
showAllItemAffixes = tostring(self.showAllItemAffixes),
767+
disableScrollControlInteraction = tostring(self.disableScrollControlInteraction),
763768
dpiScaleOverridePercent = tostring(self.dpiScaleOverridePercent),
764769
} })
765770
local res, errMsg = common.xml.SaveXMLFile(setXML, self.userPath.."Settings.xml")
@@ -844,6 +849,7 @@ function main:OpenOptionsPopup(savedState)
844849
showFlavourText = self.showFlavourText,
845850
showAnimations = self.showAnimations,
846851
showAllItemAffixes = self.showAllItemAffixes,
852+
disableScrollControlInteraction = self.disableScrollControlInteraction,
847853
dpiScaleOverridePercent = self.dpiScaleOverridePercent
848854
}
849855

@@ -1020,7 +1026,13 @@ function main:OpenOptionsPopup(savedState)
10201026
controls.showAllItemAffixes = new("CheckBoxControl", { "TOPLEFT", controls.sectionAnchor, "TOPLEFT" }, { currentX + defaultLabelPlacementX, currentY, 20 }, "^7Show all item affixes sliders:", function(state)
10211027
self.showAllItemAffixes = state
10221028
end)
1023-
controls.showAllItemAffixes.tooltipText = "Display all item affix slots as a stacked list instead of hiding them in dropdowns"
1029+
controls.showAllItemAffixes.tooltipText = "Display all item affix slots as a stacked list instead of hiding them in dropdowns."
1030+
1031+
nextRow()
1032+
controls.disableScrollControlInteraction = new("CheckBoxControl", { "TOPLEFT", controls.sectionAnchor, "TOPLEFT" }, { currentX + defaultLabelPlacementX, currentY, 20 }, "^7Disable control scroll interaction:", function(state)
1033+
self.disableScrollControlInteraction = state
1034+
end)
1035+
controls.disableScrollControlInteraction.tooltipText = "Disable changing the values in controls such as dropdowns or numeric inputs when using the scroll wheel."
10241036

10251037
nextRow()
10261038

@@ -1130,6 +1142,7 @@ function main:OpenOptionsPopup(savedState)
11301142
controls.showFlavourText.state = self.showFlavourText
11311143
controls.showAnimations.state = self.showAnimations
11321144
controls.showAllItemAffixes.state = self.showAllItemAffixes
1145+
controls.disableScrollControlInteraction.state = self.disableScrollControlInteraction
11331146

11341147
-- Adjust height in case of two-column layout
11351148
currentY = m_max(leftColumnMaxY, currentY)
@@ -1190,6 +1203,7 @@ function main:OpenOptionsPopup(savedState)
11901203
self.showFlavourText = savedState.showFlavourText
11911204
self.showAnimations = savedState.showAnimations
11921205
self.showAllItemAffixes = savedState.showAllItemAffixes
1206+
self.disableScrollControlInteraction = savedState.disableScrollControlInteraction
11931207
self.dpiScaleOverridePercent = savedState.dpiScaleOverridePercent
11941208
SetDPIScaleOverridePercent(self.dpiScaleOverridePercent)
11951209
main:ClosePopup()

0 commit comments

Comments
 (0)