Thread Tools Display Modes
09-16-19, 08:47 AM   #1
tirafesi
A Murloc Raider
Join Date: Sep 2019
Posts: 8
What's the simplest way to show a message on screen?

What's the simplest way to show a message on the screen? (outside of printing to the chat)

Something that I can show / hide whenever.
  Reply With Quote
09-16-19, 02:49 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Depends on what you're doing with the text. Essentially, text on screen are FontString objects.
__________________
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-16-19, 03:46 PM   #3
tirafesi
A Murloc Raider
Join Date: Sep 2019
Posts: 8
Originally Posted by SDPhantom View Post
Depends on what you're doing with the text. Essentially, text on screen are FontString objects.
Yeah, that's how I did it. But I was wondering if there was a more compact way of doing this without having to write 8 lines of code just to show one sentence ;-;

Code:
local msgFrame = CreateFrame("FRAME", nil, UIParent)
msgFrame:SetWidth(1)
msgFrame:SetHeight(1)
msgFrame:SetPoint("CENTER")
msgFrame:SetFrameStrata("TOOLTIP")
msgFrame.text = msgFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
msgFrame.text:SetPoint("CENTER")
msgFrame.text:SetText("Hello World")
  Reply With Quote
09-16-19, 05:17 PM   #4
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by tirafesi View Post
Yeah, that's how I did it. But I was wondering if there was a more compact way of doing this without having to write 8 lines of code just to show one sentence ;-;

Code:
local msgFrame = CreateFrame("FRAME", nil, UIParent)
msgFrame:SetWidth(1)
msgFrame:SetHeight(1)
msgFrame:SetPoint("CENTER")
msgFrame:SetFrameStrata("TOOLTIP")
msgFrame.text = msgFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
msgFrame.text:SetPoint("CENTER")
msgFrame.text:SetText("Hello World")
If you just want to quickly display some info you could use:
Code:
message("Hello World")
or you could remove creating a separate frame and just create a FontString from UIParent:
Code:
local text = UIParent:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
text:SetPoint("CENTER")
text:SetText("Hello World")
  Reply With Quote
09-16-19, 08:48 PM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
D'oh.. it didn't even occur to me that I can make my own message box rofl

A frame with a border, and YES/NO/OK buttons as needed and a text box or two ( title, content ) and turn it into a template to use as needed.
__________________
  Reply With Quote
09-17-19, 04:39 AM   #6
tirafesi
A Murloc Raider
Join Date: Sep 2019
Posts: 8
Oh, I can create the FontString directly from UIParent? Perfect! Exactly what I was looking for
  Reply With Quote
09-17-19, 11:13 AM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
If you just want text to appear on screen like an in-game message/warning would (out of range, etc.), then use the message() function.

(If that's even still in the client... It was deprecated long ago. If that doesn't work, then use UIErrorsFrame:AddMessage("text") - https://wow.gamepedia.com/API_MessageFrame_AddMessage)

If you want to control when it disappears off-screen, then create your own fontstring and show it or change the text as needed.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Classic - AddOns, Compliations, Macros » Classic - AddOn Help/Support » What's the simplest way to show a message on screen?

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