-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommands.lua
More file actions
38 lines (31 loc) · 1.22 KB
/
Copy pathCommands.lua
File metadata and controls
38 lines (31 loc) · 1.22 KB
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
local _, VoxGM = ...
local Cmd = VoxGM.Cmd
function Cmd:SendCommand(cmdStr, source)
if not cmdStr or cmdStr == "" then return end
-- Resolve the active chat edit box (supports chat addons that replace the default)
local box = ACTIVE_CHAT_EDIT_BOX or ChatFrame1EditBox
if not box then
VoxGM.Util:PrintError("No chat edit box found.")
return
end
local oldText = box:GetText()
-- Ensure the edit box is open (ChatEdit_SendText hides it after sending,
-- which breaks subsequent sends from C_Timer callbacks)
if not box:IsShown() then
ChatFrame_OpenChat("")
-- Re-resolve after opening, in case ChatFrame_OpenChat sets ACTIVE_CHAT_EDIT_BOX
box = ACTIVE_CHAT_EDIT_BOX or ChatFrame1EditBox
end
box:SetText(cmdStr)
ChatEdit_SendText(box)
box:SetText(oldText)
-- Record in history
VoxGM.History:Add(cmdStr, source or "unknown")
-- Update status bar
VoxGM.Util:StatusMessage(VoxGM.UI.mainFrame, cmdStr, VoxGM.C.COLOR_GOLD)
end
-- Toggle helpers that set expected state before sending
function Cmd:SendToggle(cmdStr, stateKey, newValue, source)
VoxGM.State.session[stateKey] = newValue
self:SendCommand(cmdStr, source or "toggle")
end