From b34044845b7580255cd40e1154769a6e462464c2 Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Tue, 25 Aug 2026 17:46:49 +0200 Subject: [PATCH] Expose ClassicAPI modifier helpers --- api.lua | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/api.lua b/api.lua index af5d9e9..09cff80 100644 --- a/api.lua +++ b/api.lua @@ -51,6 +51,10 @@ API.eventutils = type(_G.C_EventUtils) == "table" and type(_G.C_EventUtils.IsEventValid) == "function" API.modifierkeys = type(_G.IsLeftShiftKeyDown) == "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 and _G.C_EventUtils.IsEventValid("MODIFIER_STATE_CHANGED") @@ -188,8 +192,8 @@ API.GetContainerNumFreeSlots = function(bag) end -- ClassicAPI updates its own left/right modifier bitmap before firing --- MODIFIER_STATE_CHANGED. Prefer that state over vanilla IsShiftKeyDown(), --- whose merged Win32 key state can still be stale inside the event callback. +-- MODIFIER_STATE_CHANGED. Prefer that state over vanilla's merged Win32 key +-- state when the richer ClassicAPI functions are available. API.IsShiftKeyDown = function() if API.modifierkeys then return (_G.IsLeftShiftKeyDown() or _G.IsRightShiftKeyDown()) and true or false @@ -202,6 +206,30 @@ API.IsShiftKeyDown = function() return false 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 -- relying exclusively on legacy item-link parsing. local function GetItemIDFromLink(link)