|
||||||
| AddOn HELP! Requests for assistance and misc bug reports go here. | ||||||
![]() |
|
|
Thread Tools |
|
|
#11 | |
|
Seal Cub Clubbing Club
Join Date: May 2005
Location: California, US
Posts: 7,801
|
Quote:
Code:
local f = CreateFrame("ScrollingMessageFrame", "MyHistoryFrame", UIParent)
f:SetPoint("CENTER")
f:SetSize(400, 200)
f:SetFontObject(GameFontNormal)
f:SetTextColor(1, 1, 1, 1) -- default color
f:SetInsertMode("BOTTOM") -- or "TOP", where new messages appear
f:SetHyperlinksEnabled(true) -- or false, whether links are clickable
f:SetFading(true) -- or false, whether old messages fade out
f:SetFadeDuration(0.25) -- time in seconds it takes for a fading message to go from fully visible to fully hidden
f:SetTimeVisible(60) -- time in seconds before old messages start fading
f:SetMaxLines(50) -- max lines to keep in history
Code:
f:AddMessage("Here is a message!") -- will show in default color
f:AddMessage("Here is a yellow message!", 1, 1, 0) -- will show in yellow
__________________
& Author/maintainer of Grid, PhanxChat, and many more. | PM me on CurseForge Troubleshoot an addon | Turn any code into an addon | More addon resources Need help with your code? Attach or paste your whole, real files. Please don't PM me about addon bugs, requests, or code help. Post a comment, ticket, or thread instead! |
|
|
|
|
|
|
#12 |
|
Member
Join Date: Aug 2009
Posts: 15
|
Thank you for your help again
![]() I ran your code, but it doesn't do what I want: I just have lines of text floating on the screen. There is no frame, no scroll bar, no close button. In addition, I got an error regarding f:SetInsertMode("BOTTOM") so I had to mask this line. I've found this regarding the lua error. It says Blizz broke this feature. This is how it looks: ![]() Am I doing something wrong here? Last edited by Animoral; 01-20-2012 at 03:30 AM. |
|
|
|
|
|
#13 |
|
Moderator
|
Yes. You aren't defining the other frames/widgets which you said are missing - they are; all Phanx supplied was the scrolling message frame portion you asked for.
You should read up on CreateFrame and its associated functions. Also, looking at code for other AddOns which define these sorts of things (such as the code in the Interface folder of Ackis Recipe List) can aid you in adding the missing elements.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Author/Maintainer of Archy, Ackis Recipe List, Revelation, Spamalyzer, Volumizer, and many other AddOns. |
|
|
|
|
|
#14 |
|
Member
Join Date: Aug 2009
Posts: 15
|
That's the thing... I'm not that familiar with how to connect the frames together. I can make a slider frame, but I don't know how to connect it to the ScrollingMessageFrame and make them all move together, scroll and so on. This is why I was hoping to use Ace-GUI, but apparently it's not that usable.
Anyway, enough whining Few questions:1. I've looked at the addon you recommended me (Ackis Recipe List), but it doesn't use ScrollingMessageFrame. Do you have any other example for such implementation? 2. Is this the correct way to achieve what I want: a. parent "frame" b. child "ScrollingMessageFrame" c. child "slider" d. child "button" Is this the way to do it? Or did I miss something there? Thanks! |
|
|
|
|
|
#15 |
|
Moderator
|
Though it doesn't use the ScrollingMessageFrame, it does create its own scrollbars and anchors the scrolling frame it does have to a container. Using that code alongside the methods for a ScrollingMessageFrame listed here should help you along quite nicely.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Author/Maintainer of Archy, Ackis Recipe List, Revelation, Spamalyzer, Volumizer, and many other AddOns. |
|
|
|
|
|
#16 |
|
Member
Join Date: Aug 2009
Posts: 15
|
Hi,
I've tried to make the scrolling message window, but I have some problems with it. I will appreciate any help! These are my problems: 1. I don't know how to set ScrollBar:SetMinMaxValues so it will scroll according to the text scroll. I want the scroll bar and the text to be aligned. 2. When I start with the ScrollBar at the max position, the lever goes below the down button. 3. When I alt-click the up button (ScrollToTop), it's not really scrolling to top. It shows instead only the first text line, but that line appears at the bottom of the window. 4. How do I add function for dragging the scrollbar lever? 5. How do I make the frame look like a real GUI window, with title, that can be dragged, resized and so on? This is my code (you can copy and run it if you want): Code:
local historyFrame = CreateFrame("Frame", "historyFrame", UIParent)
historyFrame:SetWidth(500)
historyFrame:SetHeight(200)
historyFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
historyFrame:SetBackdrop({
bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]],
tile = true,
tileSize = 16,
})
historyFrame:SetBackdropColor(1, 1, 1)
historyFrame:EnableMouse(true)
historyFrame:EnableMouseWheel(true)
-- ScrollingMessageFrame
local historyScrollingMessage = CreateFrame("ScrollingMessageFrame", nil, historyFrame)
historyScrollingMessage:SetPoint("CENTER")
historyScrollingMessage:SetSize(500, 200)
historyScrollingMessage:SetFontObject(GameFontNormal)
historyScrollingMessage:SetTextColor(1, 1, 1, 1) -- default color
historyScrollingMessage:SetJustifyH("LEFT")
historyScrollingMessage:SetHyperlinksEnabled(true) -- or false, whether links are clickable
historyScrollingMessage:SetFading(false) -- or false, whether old messages fade out
historyScrollingMessage:SetMaxLines(50) -- max lines to keep in history
historyScrollingMessage:AddMessage("1 Here is a message!")
historyScrollingMessage:AddMessage("2 Here is a message!")
historyScrollingMessage:AddMessage("3 Here is a message!")
historyScrollingMessage:AddMessage("4 Here is a message!")
historyScrollingMessage:AddMessage("5 Here is a message!")
historyScrollingMessage:AddMessage("6 Here is a message!")
historyScrollingMessage:AddMessage("7 Here is a message!")
historyScrollingMessage:AddMessage("8 Here is a message!")
historyScrollingMessage:AddMessage("9 Here is a message!")
historyScrollingMessage:AddMessage("10 Here is a message!")
historyScrollingMessage:AddMessage("11 Here is a message!")
historyScrollingMessage:AddMessage("12 Here is a message!")
historyScrollingMessage:AddMessage("13 Here is a message!")
historyScrollingMessage:AddMessage("14 Here is a message!")
historyScrollingMessage:AddMessage("12 Here is a message!")
historyScrollingMessage:AddMessage("13 Here is a message!")
historyScrollingMessage:AddMessage("14 Here is a message!")
historyScrollingMessage:AddMessage("15 Here is a message!")
historyScrollingMessage:AddMessage("16 Here is a message!")
historyScrollingMessage:AddMessage("17 Here is a message!")
historyScrollingMessage:AddMessage("18 Here is a message!")
historyScrollingMessage:AddMessage("19 Here is a message!")
historyScrollingMessage:AddMessage("20 Here is a message!")
-------------------------------------------------------------------------------
-- Scroll bar
-------------------------------------------------------------------------------
local ScrollBar = CreateFrame("Slider", nil, historyFrame)
ScrollBar:SetPoint("TOPLEFT", historyFrame, "TOPRIGHT", 5, -11)
ScrollBar:SetPoint("BOTTOMLEFT", historyFrame, "BOTTOMRIGHT", 5, 12)
ScrollBar:SetWidth(24)
ScrollBar:EnableMouseWheel(true)
ScrollBar:SetOrientation("VERTICAL")
ScrollBar:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
ScrollBar:SetMinMaxValues(0, historyScrollingMessage:GetNumMessages())
ScrollBar:SetValueStep(1)
ScrollBar:SetValue(select(2, ScrollBar:GetMinMaxValues()))
-------------------------------------------------------------------------------
-- Scroll buttons
-------------------------------------------------------------------------------
local ScrollUpButton = CreateFrame("Button", nil, ScrollBar, "UIPanelScrollUpButtonTemplate")
ScrollUpButton:SetHeight(16)
ScrollUpButton:SetWidth(18)
ScrollUpButton:SetPoint("BOTTOM", ScrollBar, "TOP", 0, -4)
local ScrollDownButton = _G.CreateFrame("Button", nil, ScrollBar,"UIPanelScrollDownButtonTemplate")
ScrollDownButton:SetHeight(16)
ScrollDownButton:SetWidth(18)
ScrollDownButton:SetPoint("TOP", ScrollBar, "BOTTOM", 0, 4)
-----------------------
-- Scrolling functions
-----------------------
local function ScrollBar_Scroll(delta)
if not ScrollBar:IsShown() then
return
end
local cur_val = ScrollBar:GetValue()
local min_val, max_val = ScrollBar:GetMinMaxValues()
if delta < 0 and cur_val < max_val then
cur_val = math.min(max_val, cur_val + 1)
ScrollBar:SetValue(cur_val)
elseif delta > 0 and cur_val > min_val then
cur_val = math.max(min_val, cur_val - 1)
ScrollBar:SetValue(cur_val)
end
end
ScrollUpButton:SetScript("OnClick", function(self, button, down)
if _G.IsAltKeyDown() then
local min_val = ScrollBar:GetMinMaxValues()
ScrollBar:SetValue(min_val)
historyScrollingMessage:ScrollToTop()
else
ScrollBar_Scroll(1)
historyScrollingMessage:ScrollUp()
end
end)
ScrollDownButton:SetScript("OnClick", function(self, button, down)
if _G.IsAltKeyDown() then
local _, max_val = ScrollBar:GetMinMaxValues()
ScrollBar:SetValue(max_val)
historyScrollingMessage:ScrollToBottom()
else
ScrollBar_Scroll(-1)
historyScrollingMessage:ScrollDown()
end
end)
ScrollBar:SetScript("OnMouseWheel", function(self, delta)
if (delta > 0) then
historyScrollingMessage:ScrollUp()
else
historyScrollingMessage:ScrollDown()
end
ScrollBar_Scroll(delta)
end)
historyFrame:SetScript("OnMouseWheel", function(self, delta)
if (delta > 0) then
historyScrollingMessage:ScrollUp()
else
historyScrollingMessage:ScrollDown()
end
ScrollBar_Scroll(delta)
end)
|
|
|
|
![]() |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
All times are GMT. The time now is 10:03 PM.
WowAce Forums








