I’m having problems doing something very simple. I’m displaying a text label followed by a field that will have varying length text characters. I’m using display.newText and find that I can position it the way I want (using x,y values) but the updated text will move around and some times overwrite the label area.
The API states that you create the newText object with an x,y value of the “top-left corner.” It then states that the local origin is at the center of the text – which seems strange as a default mode. It does looks like the text is moving around the center of the text field. What I want is “left justified” text. I tried using object:setReferencePoint(display.TopLeftReferencePoint) but that didn’t change the text display (it did change the x and y values).
Is this a bug or is there a way to change the text display mode?
Here is my sample test code to show the issue:
-- Test code to show problem with text field changing position when updated
display.setStatusBar( display.HiddenStatusBar )
local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bkgd:setFillColor( 0, 0, 0 ) -- black background
-- This is my fixed label
txtLabel = display.newText( "Label:", 40, 60, "Verdana-Bold", 16 )
txtLabel:setTextColor( 255,255,255 )
-- This is the text field that is updated
txtCase = display.newText( "A", 105, 60, "Verdana-Bold", 16 )
txtCase:setTextColor( 255,255,255 )
txtCase:setReferencePoint(display.TopLeftReferencePoint) -- trying to change the reference point for new text
print("txtCase.x = " .. txtCase.x .. ", txtCase.y = " .. txtCase.y) -- \*\*debug
txtLabel = display.newText( "Tap screen to add a new character", 30, 200, "Verdana-Bold", 14 )
txtLabel:setTextColor( 255,255,0 )
-- Add another character for each tap
local listener = function( event )
txtCase.text = txtCase.text .. "B"
print("txtCase.x = " .. txtCase.x .. ", txtCase.y = " .. txtCase.y) -- \*\*debug
end
-- Add listener to background for user "tap"
bkgd:addEventListener( "tap", listener )
Thanks,
Tom [import]uid: 6119 topic_id: 1139 reply_id: 301139[/import]