Project: bug1.tar
App: bug1.apk
Source:
-- bug1.lua 20260503 S. Sieler
--Purpose: Demonstrate odd text truncation problem
-- Status: this version works on macOS and HTML5
-- (with minor/various changes to text/code,
-- a few 'explains' will fail on macOS, but
-- no failures observed on html5.
-- Three of the five messages are corrupted
-- on Simulator / Android.
widget = require ("widget")
local x, y, dnum, dname, contH, startX, startY, fsize
drills = {} -- see build_drills
-----------------------------------------------------------------
function bh_explain_drill (event)
local n
if (event.phase == "ended") then
n = event.target.n -- get the drill# to explain
t_comment.text = drills [n]
print ("Note: t_comment.text = " .. t_comment.text)
end
return true
end -- bh_explain_drill proc
-----------------------------------------------------------------
-----------------------------
-- build the 'drills' array of multi-line strings...
drills = {
"Drill 1 FAILS.........\n" ..
"displayed.\n" ..
"You have to pick\n" ..
"the name of the card.\n" ..
"-----------", -- BAD
"Drill 2 FAILS..................\n" ..
"Use your intuition to pick the\n" ..
"name that corresponds to that card.\n" ..
"-----------", -- BAD
"Drill 3 FAILS..................\n" ..
"add one char to next to work!!\n" ..
-- "more_text_really_long_123456789\n" .. -- works
"more_text_really_long_12345678\n" .. -- FAILS!
"name that corresponds to that card.\n" ..
"-----------", -- BAD
--[[
NOTE: in the above, if you comment out the "FAILS"
line and uncomment the "works" line (which is *longer*),
then the text displays correctly! That's *REALLY* weird!
]]
"Drill 4 works.............\n" ..
"is displayed.\n" ..
"You have to pick\n" ..
"the card (of those shown) that\n" ..
"corresponds to that number.\n" ..
"-----------", -- good
"Drill 5 works......\n" ..
"12345678901234567\n" ..
"You have to pick the number\n" ..
"that corresponds to that card.\n" ..
"-----------", --- good
-- in some builds, with some variations of *other* text
-- blocks, Drill 5 failed on macOS
}
-----------------------------
-- gui/graphics/text
contH = math.floor (display.safeActualContentHeight)
startY = math.floor (display.safeScreenOriginY + 0.5)
startX = math.floor (display.safeScreenOriginX + 0.5)
print (contH, startY)
y = startY + 10
x = startX + 30
fsize = 30
for dnum = 1, #drills do
temp = display.newText ("(explain)",
x, y, native.systemFont, fsize)
temp.n = dnum
temp:addEventListener ("touch", bh_explain_drill)
temp.anchorX = 0
y = y + 50
end
y = y + 50 -- small gap after last drill line
t_comment = display.newText ("(explanation goes here)\n\n" ..
"Tap on each of the 'explain's!",
x, y, native.systemFont, fsize)
t_comment.anchorX = 0
t_comment.anchorY = 0
y = contH * 0.7
t_note = display.newText (
"Note: *every* explanation\n" ..
"should end with a line of\n" .. "dashes!",
x, y, native.systemFont, 40)
t_note.anchorX = 0
t_note.anchorY = 0
-- NOTE: you can comment out the "addEventListenter", and
-- just uncomment the following to see bug.
-- Then, change "2" to "4" to see correct text.
-- bh_explain_drill ({phase = "ended", target = {n = 2}})
--//