Thread Tools Display Modes
01-11-24, 01:10 PM   #1
Carriola
A Murloc Raider
Join Date: Jan 2024
Posts: 4
Thank you, you were very kind to answer me. Unfortunately, however, I don't think the solutions work. From the addon channel with SendAddonMessage(MyChannelAddon_channel, msg, "WHISPER", sender) I receive the profession link of the other guildmate For example [Tailoring]. I have to put this link on a frame that collects all the links that I receive from other guildmate.

For now the only way I've found is to put a chat frame on the frame (see screen):


Code:
function LaFratellanza_Prof_ChatFrame_Init()
    local background = CreateFrame("Frame", "LaFratellanza_ChatFrame_Backgroud", LaFratellanza_main_frame);
    background:SetSize(256, 256);
    background:SetPoint("LEFT", LaFratellanza_main_frame, "TOPRIGHT", -15, -150);
    background:SetBackdrop({
        bgFile = "Interface\\AddOns\\LaFratellanza\\texture\\frames\\finestra-laterale.tga",
        tile = false,
        insets = { left = 0, right = 0, top = 0, bottom = 0 }
    });
    background:SetFrameLevel(LaFratellanza_main_frame:GetFrameLevel()-1);

    LaFratellanza_chatFrame = FCF_OpenNewWindow("LaFratellanzaProfessioni");
    LaFratellanza_chatFrameTab = _G["ChatFrame" .. LaFratellanza_chatFrame:GetID() .. "Tab"];
    LaFratellanza_chatFrameButtonFrame = _G["ChatFrame" .. LaFratellanza_chatFrame:GetID() .. "ButtonFrame"];
    LaFratellanza_chatFrameEditBox = _G["ChatFrame" .. LaFratellanza_chatFrame:GetID() .. "EditBox"];

    ChatFrame_RemoveAllMessageGroups(LaFratellanza_chatFrame);
    ChatFrame_AddMessageGroup(LaFratellanza_chatFrame, "ADDON");
    
    LaFratellanza_chatFrame:SetScript("OnEvent", function(self, event, prefix, message)
        if event == "CHAT_MSG_ADDON" and prefix == LaFratellanza_channel then
            if string.sub(message, 1, 3) == "Res" then
                self:AddMessage(string.sub(message, 5))
            end
        end
    end)
    LaFratellanza_chatFrame:RegisterEvent("CHAT_MSG_ADDON");  
	CURRENT_CHAT_FRAME_ID = LaFratellanza_chatFrame:GetID();
	FCF_ToggleLock();
	LaFratellanza_chatFrame:SetParent(_G["LaFratellanza_Main_Frame"]);
    LaFratellanza_chatFrameTab:SetParent(_G["LaFratellanza_Main_Frame"]);
    LaFratellanza_chatFrameButtonFrame:SetParent(_G["LaFratellanza_Main_Frame"]);
    LaFratellanza_chatFrameEditBox:SetParent(_G["LaFratellanza_Main_Frame"]);

	LaFratellanza_chatFrame:ClearAllPoints();
	LaFratellanza_chatFrame:SetFrameLevel(_G["LaFratellanza_Main_Frame"]:GetFrameLevel()-1);
	LaFratellanza_chatFrame:SetWidth(220);
	LaFratellanza_chatFrame:SetHeight(180);
	LaFratellanza_chatFrame:SetPoint("TOPLEFT", _G["LaFratellanza_Main_Frame"],"TOPRIGHT", 10, -70);

    LaFratellanza_chatFrameButtonFrame:SetWidth(0);
	LaFratellanza_chatFrameButtonFrame:SetHeight(0);
    LaFratellanza_chatFrameButtonFrame:ClearAllPoints();
    LaFratellanza_chatFrameButtonFrame:SetPoint("TOPRIGHT", UIParent,"TOPRIGHT", 0, 0);
    LaFratellanza_chatFrameButtonFrame:SetFrameLevel(_G["LaFratellanza_Main_Frame"]:GetFrameLevel()-1);

    LaFratellanza_chatFrameEditBox:ClearAllPoints();
    LaFratellanza_chatFrameEditBox:SetWidth(20);
    LaFratellanza_chatFrameEditBox:SetHeight(20);
    LaFratellanza_chatFrameButtonFrame:SetPoint("TOPRIGHT", UIParent,"TOPRIGHT", 0, 0);

    FCF_SetLocked( LaFratellanza_chatFrame, 1 );
    FCF_SetWindowAlpha( LaFratellanza_chatFrame, 0 );
    LaFratellanza_chatFrame:SetMovable( false );
    LaFratellanza_chatFrame:SetResizable( false );


    local header = CreateFrame("Frame", "LaFratellanza_ChatFrame_Header", LaFratellanza_main_frame);
    header:SetSize(256, 64);
    header:SetPoint("LEFT", LaFratellanza_main_frame, "TOPRIGHT", -15, -55);
    header:SetBackdrop({
        bgFile = "Interface\\AddOns\\LaFratellanza\\texture\\frames\\header-finestra-laterale.tga",
        tile = false,
        insets = { left = 0, right = 0, top = 0, bottom = 0 }
    });
    header:SetFrameLevel(LaFratellanza_chatFrameTab:GetFrameLevel()+10);

    local headerTitle = header:CreateFontString(nil, "OVERLAY", "GameFontNormal");
    headerTitle:SetPoint("TOPLEFT", header, "TOPLEFT", 30, -30);
    headerTitle:SetText("LINK PROFESSIONI");
end


screen: https://ibb.co/GxWJcMb

but unfortunately I find chat frames unpredictable. Sometimes it disappears for no reason and i can't really hide ButtonFrame, EditBox and tab of the chat.
I will try to find another way, thank you very much!

You have been very kind!

Last edited by Carriola : 01-11-24 at 01:13 PM.
  Reply With Quote
01-11-24, 01:23 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
Lightbulb

Ah, that's how you are receiving the link.

Your addon is being used by your friends and allows them to send an addon message to your addon regarding their tradeskill. Now I am assuming that if you then monitor the chat for those messages, you should be able to get the link you need to use. All you then need to do is put that link in your frame ( which I am assuming you have been doing, but are having a problem clicking on it ). The Hyperlink code we've been using should resolve that problem.

I've never used the addon message system myself so unsure of exactly what its limits are and benefits etc. But if you have that part working as expected and have a link from that source. Then things should work with the examples we've provided.

But, out of my working example the following code is what does the work

Lua Code:
  1. local cf = CreateFrame("Frame","TestFrame",UIParent)
  2. cf:SetSize(600,100)
  3. cf:SetPoint("CENTER",0,0)
  4. cf:SetHyperlinksEnabled(true)                                                    >>>> Add this to your frame
  5. cf.fs = cf:CreateFontString(nil,"OVERLAY","GameFontNormal")
  6. cf.fs:SetText(link)                                                                      >>>> This is where you put your link
  7. cf.fs:SetAllPoints()
  8. cf:SetScript("OnHyperlinkClick", ChatFrame_OnHyperlinkShow)     >>>> Add this to your frame

When you click the link it works just like the ChatFrame and opens the profession frame to the profession linked.

I've never used these myself so was quite happy to see how easy it was to work with. So I am happy to say I learned something new.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
01-11-24, 01:25 PM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,906
Originally Posted by Carriola View Post
Unfortunately, however, I don't think the solutions work.
No, it won't. You're apparently doing this for a private server and this site is only for people playing on official Blizzard servers.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-11-24, 02:40 PM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
Originally Posted by Carriola View Post
Thank you, you were very kind to answer me. Unfortunately, however, I don't think the solutions work. From the addon channel with SendAddonMessage(MyChannelAddon_channel, msg, "WHISPER", sender) I receive the profession link of the other guildmate For example [Tailoring]. I have to put this link on a frame that collects all the links that I receive from other guildmate.

For now the only way I've found is to put a chat frame on the frame (see screen):


<snipped code for brevity>

but unfortunately I find chat frames unpredictable. Sometimes it disappears for no reason and i can't really hide ButtonFrame, EditBox and tab of the chat.
I will try to find another way, thank you very much!

You have been very kind!

This works in 10.2.5 so hopefully it will work for you

How this example addon works is when you first log in / reload the ui you can open the tradeskill of your choice and it will automatically grab the skill link and send it via addonmessage to the chatframe. The addon then stops checking for the tradeskill frame being opened and closes the window. It then sees there is an addon message and grabs the link sent earlier and puts it into the fontstring set up for it.
Clicking on that link will then bring up the trade skill window ( showing the name of the link sender - in my case me ).

Looking at the tradeskill frame there is no option for WHISPERing the tradeskill link automatically as an addon message with a special prefix. So I had to use this roundabout route to get the tradeskill link and send it manually via addonmessage with the prefix.

It adds a clickable profession link to a font string so does what you are asking, you might just have to do some additional work, to make it work in your addon.

If my example doesn't work for you in 10.2.0 or 10.2.5 then mayhap something is not working right at your end and could explain the problems you are having. And as Fizzle says, we cannot help with addons not designed to work on official servers.

Lua Code:
  1. local addonName,db = ...
  2.  
  3. -- Simple Frame to display the link(s) and control how that link works when you click it
  4. local cf = CreateFrame("Frame","TestFrame",UIParent)
  5. cf:SetSize(600,100)
  6. cf:SetPoint("CENTER",0,0)
  7. cf:SetHyperlinksEnabled(true)
  8. cf:SetScript("OnHyperlinkClick", ChatFrame_OnHyperlinkShow)
  9.  
  10. -- Font string that holds the text
  11. -- I am just using one, but you could have a list of strings set up
  12. cf.fs = cf:CreateFontString(nil,"OVERLAY","GameFontNormal")
  13. cf.fs:SetAllPoints()
  14.  
  15. local function OnEvent(self,event,...)    
  16.     local args = { ... }
  17.    
  18.     -- Register addon message prefix when the addon is loaded
  19.     if event == "ADDON_LOADED" and args[1] == addonName then
  20.         local successfulRequest = C_ChatInfo.RegisterAddonMessagePrefix("XTA-AMP")
  21.         if successfulRequest then db.addonMessagePrefix = "XTA-AMP" end
  22.        
  23.     -- This is used to get the trade skill link when they open the tradeskill frame
  24.     -- If you have another way to send the addon message the link then use that
  25.     elseif event =="TRADE_SKILL_SHOW" then
  26.         self:RegisterEvent("TRADE_SKILL_LIST_UPDATE")
  27.        
  28.     elseif event == "TRADE_SKILL_LIST_UPDATE" then
  29.         local link = C_TradeSkillUI.GetTradeSkillListLink()
  30.         local success = C_ChatInfo.SendAddonMessage(db.addonMessagePrefix, link,  "WHISPER", UnitName("player"))
  31.        
  32.         -- Make sure we close the tradeskill frame and unregister events so that it doesn't trigger until the next reload
  33.         C_TradeSkillUI.CloseTradeSkill()
  34.         self:UnregisterEvent("TRADE_SKILL_LIST_UPDATE")
  35.         self:UnregisterEvent("TRADE_SKILL_SHOW")
  36.        
  37.     -- Monitor Addon messages in the chat frame
  38.     elseif event == "CHAT_MSG_ADDON" then
  39.         -- args 1 is the prefix
  40.         -- args 2 is the message
  41.         if args[1] == db.addonMessagePrefix then
  42.             -- set the profession link to the fontstring requiring it
  43.             -- remember I am using a single fontstring, if you are using multiple, make sure you are updating the correct one
  44.             cf.fs:SetText(args[2] or "")
  45.         end
  46.            
  47.     end
  48.    
  49. end
  50.  
  51. local f = CreateFrame("Frame")
  52. f:RegisterEvent("ADDON_LOADED")
  53. f:RegisterEvent("PLAYER_LOGIN")
  54. f:RegisterEvent("TRADE_SKILL_SHOW")
  55. f:RegisterEvent("CHAT_MSG_ADDON")
  56. f:SetScript("OnEvent",OnEvent)
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
01-11-24, 03:24 PM   #5
Carriola
A Murloc Raider
Join Date: Jan 2024
Posts: 4
Originally Posted by Xrystal View Post
This works in 10.2.5 so hopefully it will work for you

How this example addon works is when you first log in / reload the ui you can open the tradeskill of your choice and it will automatically grab the skill link and send it via addonmessage to the chatframe. The addon then stops checking for the tradeskill frame being opened and closes the window. It then sees there is an addon message and grabs the link sent earlier and puts it into the fontstring set up for it.
Clicking on that link will then bring up the trade skill window ( showing the name of the link sender - in my case me ).

Looking at the tradeskill frame there is no option for WHISPERing the tradeskill link automatically as an addon message with a special prefix. So I had to use this roundabout route to get the tradeskill link and send it manually via addonmessage with the prefix.

It adds a clickable profession link to a font string so does what you are asking, you might just have to do some additional work, to make it work in your addon.

If my example doesn't work for you in 10.2.0 or 10.2.5 then mayhap something is not working right at your end and could explain the problems you are having. And as Fizzle says, we cannot help with addons not designed to work on official servers.

Lua Code:
  1. local addonName,db = ...
  2.  
  3. -- Simple Frame to display the link(s) and control how that link works when you click it
  4. local cf = CreateFrame("Frame","TestFrame",UIParent)
  5. cf:SetSize(600,100)
  6. cf:SetPoint("CENTER",0,0)
  7. cf:SetHyperlinksEnabled(true)
  8. cf:SetScript("OnHyperlinkClick", ChatFrame_OnHyperlinkShow)
  9.  
  10. -- Font string that holds the text
  11. -- I am just using one, but you could have a list of strings set up
  12. cf.fs = cf:CreateFontString(nil,"OVERLAY","GameFontNormal")
  13. cf.fs:SetAllPoints()
  14.  
  15. local function OnEvent(self,event,...)    
  16.     local args = { ... }
  17.    
  18.     -- Register addon message prefix when the addon is loaded
  19.     if event == "ADDON_LOADED" and args[1] == addonName then
  20.         local successfulRequest = C_ChatInfo.RegisterAddonMessagePrefix("XTA-AMP")
  21.         if successfulRequest then db.addonMessagePrefix = "XTA-AMP" end
  22.        
  23.     -- This is used to get the trade skill link when they open the tradeskill frame
  24.     -- If you have another way to send the addon message the link then use that
  25.     elseif event =="TRADE_SKILL_SHOW" then
  26.         self:RegisterEvent("TRADE_SKILL_LIST_UPDATE")
  27.        
  28.     elseif event == "TRADE_SKILL_LIST_UPDATE" then
  29.         local link = C_TradeSkillUI.GetTradeSkillListLink()
  30.         local success = C_ChatInfo.SendAddonMessage(db.addonMessagePrefix, link,  "WHISPER", UnitName("player"))
  31.        
  32.         -- Make sure we close the tradeskill frame and unregister events so that it doesn't trigger until the next reload
  33.         C_TradeSkillUI.CloseTradeSkill()
  34.         self:UnregisterEvent("TRADE_SKILL_LIST_UPDATE")
  35.         self:UnregisterEvent("TRADE_SKILL_SHOW")
  36.        
  37.     -- Monitor Addon messages in the chat frame
  38.     elseif event == "CHAT_MSG_ADDON" then
  39.         -- args 1 is the prefix
  40.         -- args 2 is the message
  41.         if args[1] == db.addonMessagePrefix then
  42.             -- set the profession link to the fontstring requiring it
  43.             -- remember I am using a single fontstring, if you are using multiple, make sure you are updating the correct one
  44.             cf.fs:SetText(args[2] or "")
  45.         end
  46.            
  47.     end
  48.    
  49. end
  50.  
  51. local f = CreateFrame("Frame")
  52. f:RegisterEvent("ADDON_LOADED")
  53. f:RegisterEvent("PLAYER_LOGIN")
  54. f:RegisterEvent("TRADE_SKILL_SHOW")
  55. f:RegisterEvent("CHAT_MSG_ADDON")
  56. f:SetScript("OnEvent",OnEvent)

Wow thanks Xrystal!! this solution works but I don't know why (I'm a beginner addon developer :P)! You are very kind! Thanks a lot Fizzlemizz too for time and advice!
Good community
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Put a clickable professoin link on a frame


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off