Thread Tools Display Modes
01-22-24, 06:20 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
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?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
01-22-24, 07:22 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
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().
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 01-22-24 at 07:30 PM.
  Reply With Quote
01-23-24, 02:14 AM   #3
AmadiDooke
A Kobold Labourer
Join Date: Jan 2024
Posts: 1
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?
  Reply With Quote
01-23-24, 05:20 PM   #4
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
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.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
01-23-24, 05:46 PM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
In your PasteBin code,

After:
Lua Code:
  1. ScaleSlapDownButtonEditBox:SetText(scaleNumber)
add:
Lua Code:
  1. ScaleSlapDownButtonEditBox:SetCursorPosition(0)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-23-24, 06:15 PM   #6
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Fizzlemizz

That fixed it, thank you so much.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
01-24-24, 03:23 AM   #7
Awoljax
A Kobold Labourer
Join Date: Jan 2024
Posts: 1
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?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » EditBox Load text issue


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