Quantcast Beginner trouble with MessageFrame Boundaries - WoWInterface
Thread Tools Display Modes
03-27-19, 01:32 AM   #1
Yaro
A Murloc Raider
Join Date: Feb 2013
Posts: 4
Question Beginner trouble with MessageFrame Boundaries

Code:
--------------------------------------------------------------------------------------------------
-- ADDON FRAME --
--------------------------------------------------------------------------------------------------
local addon = CreateFrame("Frame", "AddonTest", UIParent)
addon.width = 300
addon.height = 300
addon:SetSize(addon.width, addon.height)

local background_texture = addon:CreateTexture("BackgroundTexture", "BACKGROUND")
background_texture:SetWidth(500)
background_texture:SetHeight(500)
background_texture:SetTexture(0,0,1, .5)
background_texture:SetAllPoints(addon)

addon:SetPoint("CENTER", 0, 0)

--interactable
addon:EnableMouse(true)
addon:EnableMouseWheel(true)

--movable
addon:SetMovable(true)
addon:RegisterForDrag("LeftButton")
addon:SetScript("OnDragStart", addon.StartMoving)
addon:SetScript("OnDragStop", addon.StopMovingOrSizing)
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
-- ADDON FRAME --> MESSAGE FRAME --
--------------------------------------------------------------------------------------------------
local messageFrame = CreateFrame("MessageFrame", nil, addon)
messageFrame:SetPoint("BOTTOMLEFT", 40, 40)
messageFrame:SetPoint("TOPRIGHT", -40, -40)
messageFrame:SetFontObject(GameFontNormal)
messageFrame:SetTextColor(1, 1, 1, 1)
messageFrame:SetJustifyH("LEFT")
messageFrame:SetFading(false)
addon.messageFrame = messageFrame

local mFrame_texture = messageFrame:CreateTexture("mFrameTexture", "BACKGROUND")
mFrame_texture:SetWidth(500)
mFrame_texture:SetHeight(500)
mFrame_texture:SetTexture(0,1,0, .5)
mFrame_texture:SetAllPoints(messageFrame)

messageFrame:AddMessage("HELLO!")
--------------------------------------------------------------------------------------------------
Resulting in:


Adding more messages ends up with:


I'm just starting out trying to throw some messages to a frame.
I added the texture to get a visual for just how big the MessageFrame was, and if I could somehow control it so that added messages wouldnt creep out of the frame.
I've tried to research this most of yesterday on my own, but I fear i lack the vocabulary for these things... I'm not even sure what the technical way would be to describe my problem, so I'm hoping one of you wizards can help me figure out what I've done wrong, and get the messages to start inside the frame.
  Reply With Quote
03-27-19, 08:24 PM   #2
kurapica.igas
A Flamescale Wyrmkin
Join Date: Aug 2011
Posts: 103
You should use the ScrollingMessageFrame instead of the MessageFrame. Like

Lua Code:
  1. local frame = TestMessage or CreateFrame("ScrollingMessageFrame", "TestMessage", UIParent)
  2.  
  3. frame:SetPoint("CENTER")
  4. frame:SetSize(300, 60)
  5. frame:SetTimeVisible(120.0);
  6. frame:SetMaxLines(128);
  7. frame:SetFontObject(ChatFontNormal);
  8. frame:SetIndentedWordWrap(true);
  9. frame:SetJustifyH("LEFT");
  10.  
  11. for i = 1, 100 do
  12.     frame:AddMessage("hello world")
  13. end

The ScrollingMessageFrame is an intrinsic type, you can find more details in https://github.com/tomrus88/Blizzard...ssageFrame.lua
  Reply With Quote
03-28-19, 02:23 AM   #3
Yaro
A Murloc Raider
Join Date: Feb 2013
Posts: 4
You should use the ScrollingMessageFrame instead of the MessageFrame.
That seems to have done the trick! It is now behaving much more, say, intuitively

Just changing from MessageFrame to ScrollingMessageFrame, and adding the lines
Lua Code:
  1. messageFrame:SetIndentedWordWrap(true);
  2. messageFrame:SetMaxLines(20)
(although the SetIndentedWordWrap wasnt strictly nessesary for the example)



and bombarding with lines


everything is sitting nicely inside the frame

- Thanks!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Beginner trouble with MessageFrame Boundaries

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