Thread Tools Display Modes
Prev Previous Post   Next Post Next
07-02-21, 12:04 AM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Set default text in a text box

Hi all

I have a frame that can be scaled via a text box.
When I reload I need the text box to be filled with the saved scale.

The frame does correctly scale based on the saved scale on reload however I have not been able to fill the text box with the saved scale value on login.

I get no errors and even when I try to hard-set a number in the text box it remains empty.

Here is my table of variables;
Lua Code:
  1. local NewbDevBoxOptionsTable = {
  2.     ButtonFrameScale = 1,
  3.     ButtonFrameOpacity = 1,
  4.     ButtonIsVisable = true
  5. }
My update frame scale;
Lua Code:
  1. local function updateButtonFrameScale(updateScaleNumber)
  2.     if updateScaleNumber >= 301 then -- if the entered number is too high
  3.         updateScaleNumber = 300
  4.     elseif updateScaleNumber <= 49 then -- if the entered number is too low
  5.         updateScaleNumber = 50
  6.     end
  7.     NewbDevBoxOptionsTable.ButtonFrameScale = updateScaleNumber / 100
  8.     NewbDevBoxButtonFrame:SetScale(NewbDevBoxOptionsTable.ButtonFrameScale)
  9.     NewbDevBoxInterfaceFrame.ScaleTextBox:SetNumber(updateScaleNumber)
  10. end
and setting the frame scale on player login
Lua Code:
  1. if event == "PLAYER_LOGIN" then
  2. NewbDevBoxButtonFrame:SetScale(NewbDevBoxOptionsTable.ButtonFrameScale)
  3. NewbDevBoxInterfaceFrame.ScaleTextBox:SetNumber(NewbDevBoxOptionsTable.ButtonFrameScale * 100)
and here is my textbox setup
Lua Code:
  1. NewbDevBoxInterfaceFrame.ScaleTextBox =
  2.     CreateFrame("EditBox", "NewbDevBoxInterfaceFrameScaleTextBox", NewbDevBoxInterfaceFrame, "OptionsBoxTemplate")
  3. NewbDevBoxInterfaceFrame.ScaleTextBox:SetPoint(
  4.     "TOPLEFT",
  5.     NewbDevBoxInterfaceFrameKeybindsButton,
  6.     "BOTTOMLEFT",
  7.     0,
  8.     NumberList.textBoxYGap
  9. )
  10. NewbDevBoxInterfaceFrame.ScaleTextBox:SetFontObject(TextDimensionList.checkBoxFont)
  11. NewbDevBoxInterfaceFrame.ScaleTextBox:SetNumeric(true)
  12. NewbDevBoxInterfaceFrame.ScaleTextBox:SetSize(NumberList.scaleTextBoxWidth, NumberList.scaleTextBoxHeight)
  13. NewbDevBoxInterfaceFrame.ScaleTextBox:SetMaxLetters(3)
  14. NewbDevBoxInterfaceFrame.ScaleTextBox:SetAutoFocus()
  15. NewbDevBoxInterfaceFrame.ScaleTextBox:SetJustifyH("CENTER")
  16. NewbDevBoxInterfaceFrame.ScaleTextBox:SetScript(
  17.     "OnEnterPressed",
  18.     function(self)
  19.         scaleNumber = tonumber(NewbDevBoxInterfaceFrame.ScaleTextBox:GetText())
  20.         self:ClearFocus()
  21.         updateButtonFrameScale(scaleNumber)
  22.     end
  23. )

I have not been able to work out why this is not working correctly, it is probably staring me in the face yet I cannot see where I have stuffed up.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Set default text in a text box

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