View Single Post
06-11-20, 08:48 AM   #5
Antiklesys
A Murloc Raider
Join Date: Jun 2020
Posts: 5
Originally Posted by Ketho View Post
You can find references by looking in some of these notepad addons
http://www.wowinterface.com/forums/s...ad.php?t=53494

I personally use the below example in my own addons


Lua Code:
  1. function KethoEditBox_Show(text)
  2.     if not KethoEditBox then
  3.         local f = CreateFrame("Frame", "KethoEditBox", UIParent, "DialogBoxFrame")
  4.         f:SetPoint("CENTER")
  5.         f:SetSize(600, 500)
  6.        
  7.         f:SetBackdrop({
  8.             bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
  9.             edgeFile = "Interface\\PVPFrame\\UI-Character-PVP-Highlight", -- this one is neat
  10.             edgeSize = 16,
  11.             insets = { left = 8, right = 6, top = 8, bottom = 8 },
  12.         })
  13.         f:SetBackdropBorderColor(0, .44, .87, 0.5) -- darkblue
  14.        
  15.         -- Movable
  16.         f:SetMovable(true)
  17.         f:SetClampedToScreen(true)
  18.         f:SetScript("OnMouseDown", function(self, button)
  19.             if button == "LeftButton" then
  20.                 self:StartMoving()
  21.             end
  22.         end)
  23.         f:SetScript("OnMouseUp", f.StopMovingOrSizing)
  24.        
  25.         -- ScrollFrame
  26.         local sf = CreateFrame("ScrollFrame", "KethoEditBoxScrollFrame", KethoEditBox, "UIPanelScrollFrameTemplate")
  27.         sf:SetPoint("LEFT", 16, 0)
  28.         sf:SetPoint("RIGHT", -32, 0)
  29.         sf:SetPoint("TOP", 0, -16)
  30.         sf:SetPoint("BOTTOM", KethoEditBoxButton, "TOP", 0, 0)
  31.        
  32.         -- EditBox
  33.         local eb = CreateFrame("EditBox", "KethoEditBoxEditBox", KethoEditBoxScrollFrame)
  34.         eb:SetSize(sf:GetSize())
  35.         eb:SetMultiLine(true)
  36.         eb:SetAutoFocus(false) -- dont automatically focus
  37.         eb:SetFontObject("ChatFontNormal")
  38.         eb:SetScript("OnEscapePressed", function() f:Hide() end)
  39.         sf:SetScrollChild(eb)
  40.        
  41.         -- Resizable
  42.         f:SetResizable(true)
  43.         f:SetMinResize(150, 100)
  44.        
  45.         local rb = CreateFrame("Button", "KethoEditBoxResizeButton", KethoEditBox)
  46.         rb:SetPoint("BOTTOMRIGHT", -6, 7)
  47.         rb:SetSize(16, 16)
  48.        
  49.         rb:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  50.         rb:SetHighlightTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  51.         rb:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  52.        
  53.         rb:SetScript("OnMouseDown", function(self, button)
  54.             if button == "LeftButton" then
  55.                 f:StartSizing("BOTTOMRIGHT")
  56.                 self:GetHighlightTexture():Hide() -- more noticeable
  57.             end
  58.         end)
  59.         rb:SetScript("OnMouseUp", function(self, button)
  60.             f:StopMovingOrSizing()
  61.             self:GetHighlightTexture():Show()
  62.             eb:SetWidth(sf:GetWidth())
  63.         end)
  64.         f:Show()
  65.     end
  66.    
  67.     if text then
  68.         KethoEditBoxEditBox:SetText(text)
  69.     end
  70.     KethoEditBox:Show()
  71. end
Hey Ketko,

I'm using this example and I'm trying to do a "Submit" form.
Basically what happens is a slashcommand brings up the edit box which is populated with the value of one of the variables in the addon.
I delete everything and the behavior I'm trying to implement is that by clicking the "Ok" button I would set a new value for that variable (the value to be set to the content of the text field).
I'm struggling with this as I don't seem to understand how the "Okay" button has been generated in the first place as it doesn't seem to be part of the code?
Any help is appreciated!
  Reply With Quote