Q: Building a Minimalist ScrollingMessageFrame

Greetings,

I am trying to display a skeletal ScrollingMessageFrame, i.e., with the minimum number of lines of code that does nothing other than display a frame. Here’s the code I have so far that I have been unable to get to display.

local smf = CreateFrame(“ScrollingMessageFrame”, nil, UIParent )
smf:SetWidth(200)
smf:SetHeight(150)
smf:SetFrameStrata(“FULLSCREEN_DIALOG”)
smf:SetJustifyH(“LEFT”)
smf:SetFading(false)
smf:SetInsertMode(“BOTTOM”)
smf:SetFontObject(“GameFontNormal”)
smf:SetMaxLines(200)
smf:EnableMouse(true)
smf:EnableMouseWheel(1)
smf:SetPoint(“CENTER”, 0, 0)
smf:SetBackdrop({
bgFile = “Interface\ChatFrame\ChatFrameBackground”, – black, opaque background
edgeFile = “Interface\DialogFrame\UI-DialogBox-Border”,
tile = true,
tileSize = 32,
edgeSize = 32,
insets = { left = 8, right = 8, top = 8, bottom = 8 } – see wow.gamepedia
})
smf:SetBackdropColor(0, 0, 0, 1)

smf:Show()

Have I missed something obvious or, because it’s a ScrollingMessageFrame, does it require the slider scrollbar frame?

Any help would be appreciated. Thanks, in advance

Here’s a basic one that fills a SMF with junk, note the ScrollFrame.

local backdrop = {
	bgFile = "Interface/BUTTONS/WHITE8X8",
	edgeFile = "Interface/GLUES/Common/Glue-Tooltip-Border",
	tile = true,
	edgeSize = 8,
	tileSize = 8,
	insets = {
		left = 5,
		right = 5,
		top = 5,
		bottom = 5,
	},
}

local listLen = 500

local function ScrollList(self)
	local offset = FauxScrollFrame_GetOffset(self)
	self:GetParent().Messages:SetScrollOffset(offset)
	FauxScrollFrame_Update(self, listLen, 25, 12 )
end

local f = CreateFrame("Frame", "MyScrollMessageTextFrame", UIParent)
f:SetSize(500, 400)
f:SetPoint("CENTER")
f:SetFrameStrata("BACKGROUND")
f:SetBackdrop(backdrop)
f:SetBackdropColor(0, 0, 0)
f.Close = CreateFrame("Button", "$parentClose", f)
f.Close:SetSize(24, 24)
f.Close:SetPoint("TOPRIGHT")
f.Close:SetNormalTexture("Interface/Buttons/UI-Panel-MinimizeButton-Up")
f.Close:SetPushedTexture("Interface/Buttons/UI-Panel-MinimizeButton-Down")
f.Close:SetHighlightTexture("Interface/Buttons/UI-Panel-MinimizeButton-Highlight", "ADD")
f.Close:SetScript("OnClick", function(self)
	self:GetParent():Hide()
end)
f.Messages = CreateFrame("ScrollingMessageFrame", "$parentMessages", f)
f.Messages:SetPoint("TOPLEFT", 15, -25)
f.Messages:SetPoint("BOTTOMRIGHT", -30, 15)
f.Messages:SetInsertMode(SCROLLING_MESSAGE_FRAME_INSERT_MODE_TOP)
f.Messages:SetMaxLines(listLen)
f.Messages:SetFading(false)
f.Messages:SetIndentedWordWrap(true)
f.Messages:SetFontObject(ChatFontNormal)
f.Messages:SetJustifyH("LEFT")
f.Scroll = CreateFrame("ScrollFrame", "$parentScroll", f, "FauxScrollFrameTemplate")
f.Scroll:SetPoint("TOPLEFT", 15, -25)
f.Scroll:SetPoint("BOTTOMRIGHT", -30, 15)
f.Scroll:SetScript("OnVerticalScroll",	function(self, offset)
	FauxScrollFrame_OnVerticalScroll(self, offset, 12, ScrollList)
end)

for i=1, listLen do
	local table = {
		"bfs fasjdf dsaf adsj fasjkf bsafjsaf bjs fasjkf bjsf basf badsjkf dsakfbhaskf asjkf asjkf skaf sak fsk fdsaf ",
		"kkl l fjds rewpwfrjpo foewf jjfwe fpwfevzv mcvn  qo fnaw[ffgngnerf we foiweffgorenfg[f fewfn sdskfn asdf sp ff",
		"q[ofkgbhp	i regp nIF N 'OFGRE  NG;G KG IGN ;EFPIREG REG  ZG;  ergregp esg gg-ero  rdf45540 4y   q8wffn ",
	}
	f.Messages:AddMessage(i.. " - "..table[random(1, 3)])
	FauxScrollFrame_Update(f.Scroll, i, 30, 12 )
end

Thanks so much. Lots to read about here and I thank you again.

However, forgive my ignorance, but how do I get it to display? When I run the code nothing is displayed. You have a function ScrollList(self) that I invoked at startup (i.e., on reload), but still nothing.

What am I missing?

You should be able to paste the code into the website addon.bool.no to create a stand-alone addon. It will create a frame in the centre of your game screen that displays a scrolling list of messages. You don’t need to do anything.

If you are using a seperate addon, make sure you are completely out of the game before testing so it can recognise any new files when you start up again.

Worked great. Didn’t know of addon.bool.no. What a great resource. Anyway, now that I have a minimalist frame up and running, I can study this working model.

Thanks again. I was quite hesitant about asking for source code, so I really appreciate what you gave me. I hope it was just a snippet you had hanging around and that didn’t cause you to put a lot of effort into it.

Cheers,

1 Like