Expose ClassicAPI modifier helpers

This commit is contained in:
Dusk-92
2026-08-25 17:46:49 +02:00
parent 8fffdff22c
commit b34044845b
+30 -2
View File
@@ -51,6 +51,10 @@ API.eventutils = type(_G.C_EventUtils) == "table"
and type(_G.C_EventUtils.IsEventValid) == "function" and type(_G.C_EventUtils.IsEventValid) == "function"
API.modifierkeys = type(_G.IsLeftShiftKeyDown) == "function" API.modifierkeys = type(_G.IsLeftShiftKeyDown) == "function"
and type(_G.IsRightShiftKeyDown) == "function" and type(_G.IsRightShiftKeyDown) == "function"
and type(_G.IsLeftControlKeyDown) == "function"
and type(_G.IsRightControlKeyDown) == "function"
and type(_G.IsLeftAltKeyDown) == "function"
and type(_G.IsRightAltKeyDown) == "function"
API.modifierstate = API.eventutils and API.modifierkeys API.modifierstate = API.eventutils and API.modifierkeys
and _G.C_EventUtils.IsEventValid("MODIFIER_STATE_CHANGED") and _G.C_EventUtils.IsEventValid("MODIFIER_STATE_CHANGED")
@@ -188,8 +192,8 @@ API.GetContainerNumFreeSlots = function(bag)
end end
-- ClassicAPI updates its own left/right modifier bitmap before firing -- ClassicAPI updates its own left/right modifier bitmap before firing
-- MODIFIER_STATE_CHANGED. Prefer that state over vanilla IsShiftKeyDown(), -- MODIFIER_STATE_CHANGED. Prefer that state over vanilla's merged Win32 key
-- whose merged Win32 key state can still be stale inside the event callback. -- state when the richer ClassicAPI functions are available.
API.IsShiftKeyDown = function() API.IsShiftKeyDown = function()
if API.modifierkeys then if API.modifierkeys then
return (_G.IsLeftShiftKeyDown() or _G.IsRightShiftKeyDown()) and true or false return (_G.IsLeftShiftKeyDown() or _G.IsRightShiftKeyDown()) and true or false
@@ -202,6 +206,30 @@ API.IsShiftKeyDown = function()
return false return false
end end
API.IsControlKeyDown = function()
if API.modifierkeys then
return (_G.IsLeftControlKeyDown() or _G.IsRightControlKeyDown()) and true or false
end
if type(_G.IsControlKeyDown) == "function" then
return _G.IsControlKeyDown() and true or false
end
return false
end
API.IsAltKeyDown = function()
if API.modifierkeys then
return (_G.IsLeftAltKeyDown() or _G.IsRightAltKeyDown()) and true or false
end
if type(_G.IsAltKeyDown) == "function" then
return _G.IsAltKeyDown() and true or false
end
return false
end
-- Direct item IDs avoid a class of Turtle WoW custom-item failures caused by -- Direct item IDs avoid a class of Turtle WoW custom-item failures caused by
-- relying exclusively on legacy item-link parsing. -- relying exclusively on legacy item-link parsing.
local function GetItemIDFromLink(link) local function GetItemIDFromLink(link)