WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Display near focus frame (https://www.wowinterface.com/forums/showthread.php?t=59224)

doofus 09-17-22 02:15 PM

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.

Fizzlemizz 09-17-22 02:59 PM

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");

doofus 09-17-22 03:24 PM

wow, it works, thanks!!!

SDPhantom 09-17-22 04:02 PM

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");

doofus 09-21-22 12:25 PM

Ah thanks, I am now doing that, no need to make an extra frame!


All times are GMT -6. The time now is 06:34 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI