View Single Post
02-03-09, 04:54 PM   #5
knifesideleft
A Defias Bandit
Join Date: Feb 2009
Posts: 2
bah

Alright so here is what ice come up with so far on a testing mod

Code:
function Dmodtest_OnLoad()
DEFAULT_CHAT_FRAME:AddMessage("Testing Mod Running")
ChatEditBox = getglobal("ChatFrameEditBox");
ChatEditBox:HookScript("OnShow", Dmodtest_OnShow)
ChatEditBox:HookScript("OnTextSet",Dmodtest_SetText)
end

function Dmodtest_OnShow()
ChatEditBox:SetText(" ")
SetEnabled = true
end

function Dmodtest_SetText()

DEFAULT_CHAT_FRAME:AddMessage("Set Text Activated")
if SetEnabled == true then
ChatEditBox:SetText("text")
SetEnabled = false
end

end

So basically every time I open the edit box it fires a blank settext to trigger what I really want in the box, and then it disables it from happening again

It works pretty good except for the Dmodtest_SetText being fired several times but its considerably better then when I had hooked OnTextChanged because it would go on firing forever. It would of worked well if I could have figured out how to unhook them after the text was posted but unless I did it wrong I guess UnHookScript doesn't exit. What I was originally going to do was Untextchanged then set text. Then use Gettext and if it matched what I wanted I would unhook it. Im just surprised it workes considering anything I used to program was just a bunch of functions with 100's of if statements and duplicate peices of code used over and over again that could of been set as just 1 function itself. I'm pretty sure that there's some obvious improvements sitting right in front of my eyes though.

Last edited by knifesideleft : 02-03-09 at 07:54 PM.
  Reply With Quote