WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Text label (https://www.wowinterface.com/forums/showthread.php?t=55140)

Marsgames 02-14-17 12:58 PM

Text label
 
Hey,

This is a really basic question but I don't find how to add some text to a frame.
I have a frame with 3 editBox
Lua Code:
  1. local function createEditBox( nomEditBox, frameParent, posX, posY, text, longueur)
  2.     local nomEditBox = CreateFrame("EditBox", tostring( nomEditBox ), frameParent, "InputBoxTemplate")
  3.     nomEditBox:SetPoint("CENTER", posX + decallageX, posY + decallageY)
  4.     nomEditBox:SetText(text)
  5.     nomEditBox:SetFrameStrata("HIGH")
  6.     nomEditBox:SetSize(longueur, 1)
  7.     nomEditBox:SetScript("OnEscapePressed", function(self)
  8.         local frame = frameParent:GetParent()
  9.         local parent = frame:GetParent()
  10.         parent:Hide()
  11.     end)
  12.  
  13.     return nomEditBox
  14. end
  15.  
  16. editBox1 = createEditBox(self, customWeightPanel, 50, 90, "Box1", 250)
  17. editBox2 = createEditBox(self, customWeightPanel, 50, 60, "Box2", 250)
  18. editBox3 = createEditBox(self, customWeightPanel, 50, 30, "Box3", 250)

And I would have a text at the right of the edit box to describe what I want to put inside

Thanks

Fizzlemizz 02-14-17 03:10 PM

Lua Code:
  1. local function createEditBox( nomEditBox, frameParent, posX, posY, text, longueur)
  2.         local nomEditBox = CreateFrame("EditBox", tostring( nomEditBox ), frameParent, "InputBoxTemplate")
  3.         nomEditBox:SetPoint("CENTER", posX + decallageX, posY + decallageY)
  4.         nomEditBox:SetText(text)
  5.         nomEditBox:SetFrameStrata("HIGH")
  6.         nomEditBox:SetSize(longueur, 1)
  7.         nomEditBox:SetScript("OnEscapePressed", function(self)
  8.             local frame = frameParent:GetParent()
  9.             local parent = frame:GetParent()
  10.             parent:Hide()
  11.         end)
  12.         nomEditBox.Label = nomEditBox:CreateFontString(nil , "BORDER", "GameFontNormal")
  13.         nomEditBox.Label:SetJustifyH("RIGHT")
  14.         nomEditBox.Label:SetPoint("TOPRIGHT", nomEditBox, "TOPLEFT", -5)
  15.         return nomEditBox
  16.     end
  17.      
  18.     editBox1 = createEditBox(self, customWeightPanel, 50, 90, "Box1", 250)
  19.     editBox1.Label:SetText("Editbox 1")
  20.     editBox2 = createEditBox(self, customWeightPanel, 50, 60, "Box2", 250)
  21.     editBox2.Label:SetText("Editbox 1")
  22.     editBox3 = createEditBox(self, customWeightPanel, 50, 30, "Box3", 250)
  23.     editBox3.Label:SetText("Editbox 1")

You could set the text in the function rather than after creating the editbox.

Marsgames 02-14-17 03:59 PM

Thank you mate, it's exactly what I wanted


All times are GMT -6. The time now is 05:29 AM.

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