mouseWheel⚓︎
The mouseWheel event fires when the mouse wheel is used, providing a delta value.
--- @param e mouseWheelEventData
local function mouseWheelCallback(e)
end
event.register(tes3.event.mouseWheel, mouseWheelCallback)
Tip
An event can be claimed by setting e.claim
to true
, or by returning false
from the callback. Claiming the event prevents any lower priority callbacks from being called.
Event Data⚓︎
delta
(number): Read-only. The direction and strength of the mouse wheel movement. The value is positive for scrolling up, negative otherwise. This magnitude is hardware dependent.isAltDown
(number): Read-only. True if alt is held.isControlDown
(number): Read-only. True if control is held.isShiftDown
(number): Read-only. True if either shift key is held.isSuperDown
(number): Read-only. True if super (Windows key) is held.
Examples⚓︎
Example: Filtering out key presses that aren't equal to the bound key combination
-- An example of a simple configuration setup
local defaultConfig = {
---@type mwseKeyMouseCombo
combo = {
-- Alt + Left mouse button
mouseButton = 0,
isAltDown = true,
isControlDown = false,
isShiftDown = false,
},
}
local config = mwse.loadConfig("myModConfig", defaultConfig)
local function registerModConfig()
local template = mwse.mcm.createTemplate({ name = "Test Mod" })
template:register()
local page = template:createSideBarPage({ label = "Settings" })
page:createKeyBinder({
label = "My combo",
description = "This combo does...",
allowMouse = true,
variable = mwse.mcm.createTableVariable({
id = "combo",
table = config
}),
})
end
event.register(tes3.event.modConfigReady, registerModConfig)
--- @param e keyDownEventData|mouseButtonDownEventData|mouseWheelEventData
local function sayHi(e)
if not tes3.isKeyEqual({ expected = config.combo, actual = e }) then
-- Nothing to do if the pressed combination isn't equal to our expected combination.
return
end
-- Now do our logic
tes3.messageBox("Hi!")
end
event.register(tes3.event.keyDown, sayHi)
event.register(tes3.event.mouseButtonDown, sayHi)
event.register(tes3.event.mouseWheel, sayHi)