Thread Tools Display Modes
09-17-22, 02:15 PM   #1
doofus
A Chromatic Dragonspawn
Join Date: Feb 2018
Posts: 158
Display near focus frame

I have an addon which wants to display something, for example "hello". I am doing this with some code I found about like this:

fNoticeBoard = CreateFrame("Frame", "DA_NoticeBoard", UIParent);
--17.3" 4K monitor
fNoticeBoard:SetPoint("CENTER",-333,-400);
fNoticeBoard:SetWidth(1);
fNoticeBoard:SetHeight(1);
fNoticeBoard:Show();
fNoticeBoard.text = fNoticeBoard:CreateFontString(nil, "OVERLAY");
fNoticeBoard.text:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE, MONOCHROME");
fNoticeBoard.text:SetPoint("LEFT", fNoticeBoard);


and to display something:

fNoticeBoard.text:SetText("Hello world");


Now, I want to be able to position this "frame" (or whatever the name is) near the focus frame, wherever the focus frame happens to be. If there is no focus frame, then of course display nothing.

Can someone please let me know how to do this?

Alternatively: allow the player to alt-shift-whatever click and drag the "Hello world" wherever they want, that will be even better. But I guess more complicated.
  Reply With Quote
09-17-22, 02:59 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Parenting takse care of show/hide, anchoring to the frame keeps it co-located,
Lua Code:
  1. fNoticeBoard = CreateFrame("Frame", "DA_NoticeBoard", FocusFrame);
  2. fNoticeBoard:SetPoint("TOP", FocusFrame, "BOTTOM", 0,-40);
  3. fNoticeBoard:SetWidth(1);
  4. fNoticeBoard:SetHeight(1);
  5. fNoticeBoard.text = fNoticeBoard:CreateFontString(nil, "OVERLAY");
  6. fNoticeBoard.text:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE, MONOCHROME");
  7. fNoticeBoard.text:SetPoint("TOP", fNoticeBoard);
  8. fNoticeBoard.text:SetText("Hello world");
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-17-22 at 03:09 PM.
  Reply With Quote
09-17-22, 03:24 PM   #3
doofus
A Chromatic Dragonspawn
Join Date: Feb 2018
Posts: 158
wow, it works, thanks!!!
  Reply With Quote
09-17-22, 04:02 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,322
Additionally, if all you want to do is create a FontString anchored to an existing frame, you don't need to create a new frame just to do it.

Lua Code:
  1. local NoticeText=FocusFrame:CreateFontString(nil,"OVERLAY");
  2. NoticeText:SetFont("Fonts\\FRIZQT__.TTF",18,"OUTLINE, MONOCHROME");
  3. NoticeText:SetPoint("TOP",FocusFrame,"BOTTOM",0,-40);
  4. NoticeText:SetText("Hello world");
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
09-21-22, 12:25 PM   #5
doofus
A Chromatic Dragonspawn
Join Date: Feb 2018
Posts: 158
Ah thanks, I am now doing that, no need to make an extra frame!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Display near focus frame

Thread Tools
Display Modes

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