WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   EditBox Load text issue (https://www.wowinterface.com/forums/showthread.php?t=59768)

Walkerbo 01-22-24 06:20 PM

EditBox Load text issue
 
Hi all

I have a strange bug where I try to load text into an edit box on load.
I can load the text but it does not show until I click on the edit box and right arrow until the text shows.


Here is my lua file.
Here is my toc file.

updateTextFucntion - line 139

run updateTextFucntion(scaleNumber) in playerLogin event - line 250

scaleTextEditBox - line 309

Can anyone tell me what I am doing wrong?

SDPhantom 01-22-24 07:22 PM

Did you try making the EditBox wider? It looks like the text is having problems fitting all 3 digits until you move the cursor back to the beginning. It's possible it could be some anomaly in an attempt to word wrap or truncate.

You also may want to try tweaking :SetTextInsets().

AmadiDooke 01-23-24 02:14 AM

Have you considered adjusting the width of the EditBox or experimenting with :SetTextInsets() to resolve the issue of text not displaying properly until you interact with it?

Walkerbo 01-23-24 05:20 PM

Hi SDPhantom and AmadiDooke

Yes, I have already tried expanding the edit box and adjusting the insets, all without success.
When I try a test of just the edit box using the following code it works perfectly;

Lua Code:
  1. local TestScaleNumber = 123
  2.  
  3. local function updateTextBoxNumber(scaleNumber)
  4.    if scaleNumber >= 301 then -- if the entered number is too high
  5.       scaleNumber = 300
  6.    elseif scaleNumber <= 49 then -- if the entered number is too low
  7.       scaleNumber = 50
  8.    end
  9.    TestScaleNumber = scaleNumber / 100
  10.    TestScaleBox:SetText(scaleNumber)  
  11. end
  12.  
  13. local TestScaleBox =
  14. CreateFrame("EditBox", "TestScaleBox", UIParent, "ChatConfigBoxTemplate")
  15. TestScaleBox:SetPoint("CENTER")
  16. TestScaleBox:SetFontObject(NumberFontNormalLargeYellow)
  17. TestScaleBox:SetNumeric(true)
  18. TestScaleBox:SetSize(40, 25)
  19. TestScaleBox:SetMaxLetters(3)
  20. TestScaleBox:SetAutoFocus()
  21. TestScaleBox:SetText("")
  22. TestScaleBox:SetJustifyH("CENTER")
  23. TestScaleBox:SetScript(
  24.    "OnEnterPressed",
  25.    function(self)
  26.       scaleNumber = tonumber(TestScaleBox:GetText())
  27.       print(scaleNumber) -- debug --
  28.       self:ClearFocus()
  29.       updateTextBoxNumber(scaleNumber)
  30.    end
  31. )
  32.  
  33. updateTextBoxNumber(TestScaleNumber)

This code uses the same edit box code and the same function code, other than the UIParent.

Fizzlemizz 01-23-24 05:46 PM

In your PasteBin code,

After:
Lua Code:
  1. ScaleSlapDownButtonEditBox:SetText(scaleNumber)
add:
Lua Code:
  1. ScaleSlapDownButtonEditBox:SetCursorPosition(0)

Walkerbo 01-23-24 06:15 PM

Hi Fizzlemizz

That fixed it, thank you so much.

Awoljax 01-24-24 03:23 AM

Have you considered using the solution provided by Fizzlemizz, which involves adding the line "ScaleSlapDownButtonEditBox:SetCursorPosition(0)" after the line "ScaleSlapDownButtonEditBox:SetText(scaleNumber)" in your PasteBin code to address the issue of text not displaying properly until interaction?


All times are GMT -6. The time now is 07:10 PM.

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