I was wondering if i could get a bit of help with something. The current way that the achievement panel works you can shift click an achievement and add that link to the message you are typing.
What i wanted help with was intercepting the achievement link when my editbox has focus and when the achievement is shift clicked
edit: If a mod sees this can they move it to "Development Help" please
local orig = AchievementButton_OnClick
AchievementButton_OnClick = function(self, button, down, ignoreModifiers)
if IsModifiedClick() and not ignoreModifiers then
if IsModifiedClick("CHATLINK") and MyEditBox:IsShown() then
local achievementLink = GetAchievementLink(self.id)
if achievementLink then
return MyEditBox:Insert(achievementLink)
end
end
end
return orig(self, button, down, ignoreModifiers)
end
Obviously, change "MyEditBox" to the name of, or a reference to, your editbox frame.
You could hooksecurefunc("AchievementButton_OnClick", "yourfunctionhere")
local function yourfunctionhere(self, button, down, ignoreModifiers)
local achLink = GetAchievementLink(self.id)
-- do whatever you want with the link then.
end
Keep in mind Blizzard_AchievementUI is load on demand so you need to set your hook after you detect it loaded in ADDON_LOADED event with arg1 == "Blizzard_AchievementUI".
Edit: The hell, 2nd time this week I post in parallel to Phanx.
Thanks guys, here is what i decided to go with in the end. This grabs the links from achievements and quests
WoWPuG_OnAddonLoadCatcher = CreateFrame("Frame");
WoWPuG_OnAddonLoadCatcher:SetScript("OnEvent", function(self, event, ...)
local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 = ...;
if arg1 == "Blizzard_AchievementUI" then
WoWPuG_SetupAchievementGrabber();
end
end)
WoWPuG_OnAddonLoadCatcher:RegisterEvent("ADDON_LOADED");
function WoWPuG_SetupQuestGrabber()
local function QuestLinkGrabber(self, button, down, ignoreModifiers)
local questLink = GetQuestLink(self:GetID())
WoWPuG_AddLinkToMessage(questLink)
end
hooksecurefunc("QuestLogTitleButton_OnClick", QuestLinkGrabber)
end
function WoWPuG_SetupAchievementGrabber()
local function AchievementLinkGrabber(self, button, down, ignoreModifiers)
local achLink = GetAchievementLink(self.id)
WoWPuG_AddLinkToMessage(achLink)
end
hooksecurefunc("AchievementButton_OnClick", AchievementLinkGrabber)
end
function WoWPuG_AddLinkToMessage(Link)
if WPuG_SetupGrp_MessageBox then -- if the edit box has loaded
if IsModifiedClick() then -- if we are holding a modifier (alt/ctrl/shift)
if WPuG_SetupGrp_MessageBox:HasFocus() then -- if the editbox has focus
WPuG_SetupGrp_MessageBox:Insert(Link) -- then add the link to the message
end
end
end
end
I use a much simpler method in LFMonitor to intercept any link like this. In the following code, LFMonitor.EditFocus is the edit box in my addon which currently has focus. Pretty sure I stole this code from somewhere but can't remember where, so all credit to the original author.
local orig_ChatEdit_GetActiveWindow = ChatEdit_GetActiveWindow
function ChatEdit_GetActiveWindow()
return LFMonitor.EditFocus or orig_ChatEdit_GetActiveWindow()
end
WoWPuG_OnAddonLoadCatcher:SetScript("OnEvent", function(self, event, ...)
local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 = ...;
if arg1 == "Blizzard_AchievementUI" then
Just curious... why bother using a vararg, when you immediately assigning to to individual variables and then only use the first value, instead of just naming the incoming parameter directly?
WoWPuG_OnAddonLoadCatcher:SetScript("OnEvent", function(self, event, addon)
if addon == "Blizzard_AchievementUI" then
I use a much simpler method in LFMonitor to intercept any link like this. In the following code, LFMonitor.EditFocus is the edit box in my addon which currently has focus. Pretty sure I stole this code from somewhere but can't remember where, so all credit to the original author.
local orig_ChatEdit_GetActiveWindow = ChatEdit_GetActiveWindow
function ChatEdit_GetActiveWindow()
return LFMonitor.EditFocus or orig_ChatEdit_GetActiveWindow()
end
This is the best idea yet. It grabs item links, quests and achievements. Thank you so much. Although I couldnt get it to work i changed it to:
function WoWPuG_SetupQuestGrabber()
-- Use my editbox as the active window
local orig_ChatEdit_GetActiveWindow = ChatEdit_GetActiveWindow
function ChatEdit_GetActiveWindow()
if WPuG_SetupGrp_MessageBox:HasFocus() then -- if my editbox has focus
return WPuG_SetupGrp_MessageBox
else
return orig_ChatEdit_GetActiveWindow()
end
end
end
WoWPuG_OnAddonLoadCatcher:SetScript("OnEvent", function(self, event, ...)
local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 = ...;
if arg1 == "Blizzard_AchievementUI" then
Just curious... why bother using a vararg, when you immediately assigning to to individual variables and then only use the first value, instead of just naming the incoming parameter directly?
WoWPuG_OnAddonLoadCatcher:SetScript("OnEvent", function(self, event, addon)
if addon == "Blizzard_AchievementUI" then
Mostly just sticking to old habits, then when i am looking around going "how did i do xxx?" its easier to see
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I was wondering if i could get a bit of help with something. The current way that the achievement panel works you can shift click an achievement and add that link to the message you are typing.
What i wanted help with was intercepting the achievement link when my editbox has focus and when the achievement is shift clicked
edit: If a mod sees this can they move it to "Development Help" please
Obviously, change "MyEditBox" to the name of, or a reference to, your editbox frame.
local function yourfunctionhere(self, button, down, ignoreModifiers)
local achLink = GetAchievementLink(self.id)
-- do whatever you want with the link then.
end
Keep in mind Blizzard_AchievementUI is load on demand so you need to set your hook after you detect it loaded in ADDON_LOADED event with arg1 == "Blizzard_AchievementUI".
Edit: The hell, 2nd time this week I post in parallel to Phanx.
Just curious... why bother using a vararg, when you immediately assigning to to individual variables and then only use the first value, instead of just naming the incoming parameter directly?
This is the best idea yet. It grabs item links, quests and achievements. Thank you so much. Although I couldnt get it to work i changed it to:
Mostly just sticking to old habits, then when i am looking around going "how did i do xxx?" its easier to see