-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChatScrolling.lua
41 lines (36 loc) · 915 Bytes
/
ChatScrolling.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
local feature = ns.Register({
identifier = "ChatScrolling",
description = "Allows to scroll in chat using the mouse wheel.",
category = "social",
config = {
scrollSpeed = 1,
}
})
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
local function ChatOnMouseWheel()
if arg1 > 0 then
if IsShiftKeyDown() then
this:ScrollToTop()
else
for i=1, feature.config.scrollSpeed do
this:ScrollUp()
end
end
elseif arg1 < 0 then
if IsShiftKeyDown() then
this:ScrollToBottom()
else
for i=1, feature.config.scrollSpeed do
this:ScrollDown()
end
end
end
end
frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then return end
for i=1, NUM_CHAT_WINDOWS do
_G["ChatFrame" .. i]:EnableMouseWheel(true)
_G["ChatFrame" .. i]:SetScript("OnMouseWheel", ChatOnMouseWheel)
end
end)