Thread Tools Display Modes
04-06-21, 04:47 PM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
insertedFrame for StaticPopup_Show() not working

I want to display some easy-to-copy text in a popup dialog.

So I thought StaticPopup_Show() with an edit box as the 'insertedFrame' argument would be the straight forward way to achieve this.

But for some reason, passing the frame to StaticPopup_Show() like this does not do anything at all:

Lua Code:
  1. local scrollFrame = CreateFrame("ScrollFrame", nil, nil, "UIPanelScrollFrameTemplate")
  2. scrollFrame:SetSize(300, 80)
  3. scrollFrame:SetPoint("CENTER")
  4.  
  5. local editbox = CreateFrame("EditBox", nil, scrollFrame, "InputBoxScriptTemplate")
  6. editbox:SetMultiLine(true)
  7. editbox:SetAutoFocus(false)
  8. editbox:SetFontObject(ChatFontNormal)
  9. editbox:SetWidth(300)
  10. editbox:SetText("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n")
  11. editbox:SetCursorPosition(0)
  12. scrollFrame:SetScrollChild(editbox)
  13.  
  14. StaticPopupDialogs["MY_TEST"] = {
  15.     text = "Test",
  16.     button1 = "OK",
  17. }
  18.  
  19. StaticPopup_Show("MY_TEST", scrollFrame)


When I look at the code of StaticPopup_Show(), I cannot see why it should not work:
https://github.com/Gethe/wow-ui-sour...opup.lua#L4583

Can anybody explain this to me? Thanks!
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
04-06-21, 06:13 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
insertedFrame is the 5th parameter and the function doesn't do parameter substitution.

Code:
StaticPopup_Show("MY_TEST", nil, nil, nil, scrollFrame)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-06-21 at 06:16 PM.
  Reply With Quote
04-07-21, 12:33 AM   #3
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Originally Posted by Fizzlemizz View Post
insertedFrame is the 5th parameter and the function doesn't do parameter substitution.[/code]
Ah, thanks so much. I should have taken a closer look at:
https://github.com/Gethe/wow-ui-sour...opup.lua#L4313

:-) Works perfectly now.

A little follow-up question, if I may?
I would like to have the "TooltipBackdropTemplate" border and background for my scroll box.
Do I have to create a new frame for this, or is there a way to use both "UIPanelScrollFrameTemplate" and "TooltipBackdropTemplate" on scrollFrame at the same time?

Thanks again!
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
04-07-21, 12:37 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Inheriting multiple templates just requires a comma delimited list

local scrollFrame = CreateFrame("ScrollFrame", nil, nil, "UIPanelScrollFrameTemplate, TooltipBackdropTemplate")
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
04-07-21, 12:41 AM   #5
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Thanks for the quick reply! So simple.

But apparently due to the nature of UIPanelScrollFrameTemplate this does not include the scroll bar in the box and the box is also a few pixels to small. So I guess I have to create a custom child frame of scrollFrame for TooltipBackdropTemplate after all, right?
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
04-07-21, 12:53 AM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
If it's just for Copy/Paste the scrollbar will be pretty useless when they can just CTRL-A/CTRL-C. You can probably hide the bar.

StaticPopup is using the size of the frame you passed it and the scrollbar is another frame attached to the right hand side of it in the creation of the UIPanelScrollFrameTemplate.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-07-21 at 12:56 AM.
  Reply With Quote
04-07-21, 12:58 AM   #7
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Originally Posted by Fizzlemizz View Post
If it's just for Copy/Paste the scrollbar will be pretty useless when they can just CTRL-A/CTRL-C. You can probably hide the bar.

StaticPopup is using the size of the frame you passed it and the scrollbar is another frame attached to the right hand side of it in the creation of the UIPanelScrollFrameTemplate.

Right, I ended up doing it like this:

Lua Code:
  1. local scrollBoxWidth = 400
  2. local scrollBoxHeight = 120
  3.  
  4. local outerFrame = CreateFrame("Frame")
  5. outerFrame:SetSize(scrollBoxWidth + 80, scrollBoxHeight + 20)
  6.  
  7. local borderFrame = CreateFrame("Frame", nil, outerFrame, "TooltipBackdropTemplate")
  8. borderFrame:SetSize(scrollBoxWidth + 34, scrollBoxHeight + 10)
  9. borderFrame:SetPoint("CENTER")
  10.  
  11. local scrollFrame = CreateFrame("ScrollFrame", nil, outerFrame, "UIPanelScrollFrameTemplate")
  12. scrollFrame:SetPoint("CENTER", -10, 0)
  13. scrollFrame:SetSize(scrollBoxWidth, scrollBoxHeight)
  14.  
  15.  
  16. local editbox = CreateFrame("EditBox", nil, scrollFrame, "InputBoxScriptTemplate")
  17. editbox:SetMultiLine(true)
  18. editbox:SetAutoFocus(false)
  19. editbox:SetFontObject(ChatFontNormal)
  20. editbox:SetWidth(scrollBoxWidth)
  21. editbox:SetText("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n")
  22. editbox:SetCursorPosition(0)
  23. scrollFrame:SetScrollChild(editbox)
  24.  
  25. StaticPopupDialogs["MY_TEST"] = {
  26.     text = "Test",
  27.     button1 = "OK",
  28. }
  29.  
  30. local dialog = StaticPopup_Show("MY_TEST", nil, nil, nil, outerFrame)



Thanks again!
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » insertedFrame for StaticPopup_Show() not working

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