I'm quite new to addon design, and I'm making my addon an Ace3 addon.
One of the features I want to implement is "whisper history window", which will do the following:
1. The history window will be a dragable window with a "close" button.
2. The window will be openned by a slash command or a button in the addon config panel.
3. The window will contain rows of text taken from the savedVariable. each row will be history of a chat whisper, and will include 3 fields: date/time, sender, message.
4. The window will contain a scrolling bar, in case there are too many whispers to show.
Can it be done using Ace3 libs?
I will be thankfull for any help, guidance or links to a relevant doc.
1. you need this
2.&4. read about this and AceConfig
3. AceDB , and you need do some research on "CHAT_MSG_BN_WHISPER" & "CHAT_MSG_WHISPER" 2 events, which will fired when you got wisper message
Thank you for your answer.
I'm already read these documents. I know how to collect the whispers data. What I'm missing is how to use the ACE GUI: how to actually draw the window, how to display the text lines in it (assuming I already have it in a table), how to make it scrollable.
Don't use AceGUI. There is pretty much no reason for anyone to ever use AceGUI directly. If what you want to do can't be done with an options table through AceConfig, just build your own GUI using the standard widget API.
I tried working with the standard API, but making a scrollframe for text was a bit complex for me. Other addons I looked at did it with XML. So I ended up using Ace-GUI, and it worked.
Only problem is the window is not being closed when hitting "escape", and this is very annoying. Any idea how to make it close with "escape"?
This is my code:
I tried working with the standard API, but making a scrollframe for text was a bit complex for me. Other addons I looked at did it with XML.
local f = CreateFrame("[URL="http://www.wowpedia.org/Widget_API#ScrollingMessageFrame"][B][U]ScrollingMessageFrame[/U][/B][/URL]", "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
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
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.
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.
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.
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?
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.
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):
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)
I'm quite new to addon design, and I'm making my addon an Ace3 addon.
One of the features I want to implement is "whisper history window", which will do the following:
1. The history window will be a dragable window with a "close" button.
2. The window will be openned by a slash command or a button in the addon config panel.
3. The window will contain rows of text taken from the savedVariable. each row will be history of a chat whisper, and will include 3 fields: date/time, sender, message.
4. The window will contain a scrolling bar, in case there are too many whispers to show.
Can it be done using Ace3 libs?
I will be thankfull for any help, guidance or links to a relevant doc.
Thanks :)
2.&4. read about this and AceConfig
3. AceDB , and you need do some research on "CHAT_MSG_BN_WHISPER" & "CHAT_MSG_WHISPER" 2 events, which will fired when you got wisper message
Thank you for your answer.
I'm already read these documents. I know how to collect the whispers data. What I'm missing is how to use the ACE GUI: how to actually draw the window, how to display the text lines in it (assuming I already have it in a table), how to make it scrollable.
Thanks :)
- http://www.wowpedia.org/Widget_API
- http://www.wowpedia.org/Widget_Handlers
I tried working with the standard API, but making a scrollframe for text was a bit complex for me. Other addons I looked at did it with XML. So I ended up using Ace-GUI, and it worked.
Only problem is the window is not being closed when hitting "escape", and this is very annoying. Any idea how to make it close with "escape"?
This is my code:
Thanks!
I saw that before posting here, but it didn't work. I guess I didn't manage to add to my code correctly.
What is the exact line I should add?
Can I override it from my addon and give the frame a name?
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?
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.
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!
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):
Thanks :)