WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   insertedFrame for StaticPopup_Show() not working (https://www.wowinterface.com/forums/showthread.php?t=58679)

LudiusMaximus 04-06-21 04:47 PM

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!

Fizzlemizz 04-06-21 06:13 PM

insertedFrame is the 5th parameter and the function doesn't do parameter substitution.

Code:

StaticPopup_Show("MY_TEST", nil, nil, nil, scrollFrame)

LudiusMaximus 04-07-21 12:33 AM

Quote:

Originally Posted by Fizzlemizz (Post 338828)
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!

Fizzlemizz 04-07-21 12:37 AM

Inheriting multiple templates just requires a comma delimited list

local scrollFrame = CreateFrame("ScrollFrame", nil, nil, "UIPanelScrollFrameTemplate, TooltipBackdropTemplate")

LudiusMaximus 04-07-21 12:41 AM

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?

Fizzlemizz 04-07-21 12:53 AM

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.

LudiusMaximus 04-07-21 12:58 AM

Quote:

Originally Posted by Fizzlemizz (Post 338837)
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!


All times are GMT -6. The time now is 09:32 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI