Files

57 lines
3.1 KiB
Lua

-- OctoTextSize: addon-local factory; Blizzard CreateFrame is unchanged.
local CreateFrame = OctoTextSize and OctoTextSize.WrapFactory(CreateFrame) or CreateFrame
-- Hoverbind: the native Quick Keybind mode, reachable from Options > Keybindings (Claude lane, 2026-11-22).
-- The 70334 client ships Blizzard_QuickKeybind and its action buttons already carry the QuickKeybind handlers
-- (hover a button, press a key / mouse button / wheel to bind it, Escape on it to unbind), but the
-- Camelot KeybindingsOverrides.CreateBindingButtonSettings omits the button that opens it. This adds that row,
-- built with the stock CreateSettingsButtonInitializer, directly below "Character Specific Keybindings".
-- No Blizzard function or global is replaced; the row is inserted into the Keybindings layout's initializer list.
-- /hoverbind opens the same mode.
WoWHybridUI = WoWHybridUI or {}
local state = WoWHybridUI
local function OpenQuickKeybind()
if InCombatLockdown() then
UIErrorsFrame:AddMessage(ERR_NOT_IN_COMBAT or "You can't do that while in combat", 1, 0.1, 0.1)
return
end
if not QuickKeybindFrame and C_AddOns and C_AddOns.LoadAddOn then C_AddOns.LoadAddOn("Blizzard_QuickKeybind") end
if not QuickKeybindFrame then return end
if SettingsPanel and SettingsPanel:IsShown() then
local skipTransitionBackToOpeningPanel = true
SettingsPanel:Close(skipTransitionBackToOpeningPanel)
end
QuickKeybindFrame:Show()
end
state.OpenQuickKeybind = OpenQuickKeybind
local function Install()
if state.hoverbindInstalled then return true end
if type(Settings) ~= "table" or not Settings.KEYBINDINGS_CATEGORY_ID or type(CreateSettingsButtonInitializer) ~= "function"
or not SettingsPanel or type(SettingsPanel.GetLayout) ~= "function" then return false end
local category = Settings.GetCategory and Settings.GetCategory(Settings.KEYBINDINGS_CATEGORY_ID)
local layout = category and SettingsPanel:GetLayout(category)
local list = layout and layout.GetInitializers and layout:GetInitializers()
if type(list) ~= "table" then return false end
local label = SETTINGS_QUICK_KEYBIND_BUTTON or QUICK_KEYBIND_MODE or "Quick Keybind Mode"
local tooltip = "Hover over an action bar button and press a key, mouse button or mouse wheel to bind it. " ..
"Escape on a hovered button clears its binding; Okay saves, Cancel reverts. Also: /hoverbind"
local addSearchTags = true
local initializer = CreateSettingsButtonInitializer("Hoverbind", label, OpenQuickKeybind, tooltip, addSearchTags)
-- Position 2: right after the Character Specific Keybindings checkbox, above every binding section.
table.insert(list, math.min(2, #list + 1), initializer)
state.hoverbindInstalled = true
return true
end
SLASH_WOWHYBRIDHOVERBIND1 = "/hoverbind"
SlashCmdList.WOWHYBRIDHOVERBIND = OpenQuickKeybind
local events = CreateFrame("Frame")
events:RegisterEvent("PLAYER_LOGIN")
events:RegisterEvent("ADDON_LOADED")
events:SetScript("OnEvent", function()
if Install() then events:UnregisterAllEvents() end
end)
if SettingsPanel then SettingsPanel:HookScript("OnShow", Install) end