Skip to content

Commit 22fba52

Browse files
vaisestLocalIdentity
andauthored
Add option to disable scroll wheel interacting with controls (#2176)
* Allow disabling scroll interacting with controls * Revert SliderControl.lua (It actually makes sense here imo) * Only block scroll wheel, not arrow keys * Fix tooltip + cancel selection The tooltip still mentioned scroll bars When pressing cancel it wasn't reverting to the previous choice --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent 771452f commit 22fba52

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
@@ -462,6 +462,9 @@ function DropDownClass:OnKeyUp(key)
462462
if self.dropped and self.controls.scrollBar.enabled then
463463
self.controls.scrollBar:Scroll(1)
464464
else
465+
if main.disableScrollControlInteraction and key == "WHEELDOWN" then
466+
return
467+
end
465468
self:SetSel(self:ListIndexToDropIndex(self.selIndex, 0) + 1)
466469
end
467470
return self
@@ -473,6 +476,9 @@ function DropDownClass:OnKeyUp(key)
473476
if self.dropped and self.controls.scrollBar.enabled then
474477
self.controls.scrollBar:Scroll(-1)
475478
else
479+
if main.disableScrollControlInteraction and key == "WHEELUP" then
480+
return
481+
end
476482
self:SetSel(self:ListIndexToDropIndex(self.selIndex, 0) - 1)
477483
end
478484
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 then
690690
local value = cur - (self.numberInc or 1)
691691
if self.filter == "%D" or self.filter == "^%d." then

src/Modules/Main.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ function main:Init()
115115
self.showFlavourText = true
116116
self.showAnimations = true
117117
self.showAllItemAffixes = true
118+
self.disableScrollControlInteraction = false
118119
self.errorReadingSettings = false
119120

120121
if not SetDPIScaleOverridePercent then SetDPIScaleOverridePercent = function(scale) end end
@@ -662,6 +663,9 @@ function main:LoadSettings(ignoreBuild)
662663
if node.attrib.showAllItemAffixes then
663664
self.showAllItemAffixes = node.attrib.showAllItemAffixes == "true"
664665
end
666+
if node.attrib.disableScrollControlInteraction then
667+
self.disableScrollControlInteraction = node.attrib.disableScrollControlInteraction == "true"
668+
end
665669
if node.attrib.dpiScaleOverridePercent then
666670
self.dpiScaleOverridePercent = tonumber(node.attrib.dpiScaleOverridePercent) or 0
667671
SetDPIScaleOverridePercent(self.dpiScaleOverridePercent)
@@ -797,6 +801,7 @@ function main:SaveSettings()
797801
showFlavourText = tostring(self.showFlavourText),
798802
showAnimations = tostring(self.showAnimations),
799803
showAllItemAffixes = tostring(self.showAllItemAffixes),
804+
disableScrollControlInteraction = tostring(self.disableScrollControlInteraction),
800805
dpiScaleOverridePercent = tostring(self.dpiScaleOverridePercent)
801806
} })
802807
local res, errMsg = common.xml.SaveXMLFile(setXML, self.userPath.."Settings.xml")
@@ -881,6 +886,7 @@ function main:OpenOptionsPopup(savedState)
881886
showFlavourText = self.showFlavourText,
882887
showAnimations = self.showAnimations,
883888
showAllItemAffixes = self.showAllItemAffixes,
889+
disableScrollControlInteraction = self.disableScrollControlInteraction,
884890
dpiScaleOverridePercent = self.dpiScaleOverridePercent
885891
}
886892

@@ -1052,7 +1058,13 @@ function main:OpenOptionsPopup(savedState)
10521058
controls.showAllItemAffixes = new("CheckBoxControl", { "TOPLEFT", controls.sectionAnchor, "TOPLEFT" }, { currentX + defaultLabelPlacementX, currentY, 20 }, "^7Show all item affixes sliders:", function(state)
10531059
self.showAllItemAffixes = state
10541060
end)
1055-
controls.showAllItemAffixes.tooltipText = "Display all item affix slots as a stacked list instead of hiding them in dropdowns"
1061+
controls.showAllItemAffixes.tooltipText = "Display all item affix slots as a stacked list instead of hiding them in dropdowns."
1062+
1063+
nextRow()
1064+
controls.disableScrollControlInteraction = new("CheckBoxControl", { "TOPLEFT", controls.sectionAnchor, "TOPLEFT" }, { currentX + defaultLabelPlacementX, currentY, 20 }, "^7Disable control scroll interaction:", function(state)
1065+
self.disableScrollControlInteraction = state
1066+
end)
1067+
controls.disableScrollControlInteraction.tooltipText = "Disable changing the values in controls such as dropdowns or numeric inputs when using the scroll wheel."
10561068

10571069
nextRow()
10581070

@@ -1169,6 +1181,7 @@ function main:OpenOptionsPopup(savedState)
11691181
controls.showFlavourText.state = self.showFlavourText
11701182
controls.showAnimations.state = self.showAnimations
11711183
controls.showAllItemAffixes.state = self.showAllItemAffixes
1184+
controls.disableScrollControlInteraction.state = self.disableScrollControlInteraction
11721185

11731186
-- Adjust height in case of two-column layout
11741187
currentY = m_max(leftColumnMaxY, currentY)
@@ -1230,6 +1243,7 @@ function main:OpenOptionsPopup(savedState)
12301243
self.showFlavourText = savedState.showFlavourText
12311244
self.showAnimations = savedState.showAnimations
12321245
self.showAllItemAffixes = savedState.showAllItemAffixes
1246+
self.disableScrollControlInteraction = savedState.disableScrollControlInteraction
12331247
self.dpiScaleOverridePercent = savedState.dpiScaleOverridePercent
12341248
SetDPIScaleOverridePercent(self.dpiScaleOverridePercent)
12351249
main:ClosePopup()

0 commit comments

Comments
 (0)