I am developing a calculator. the numbers must be of course right aligned on the display. i am using the font courier, because i thought with monospaced fonts i don’t run into trouble. On the simulator all is fine, but on device the numbers are moving everytime i am making display output with display.newText between i think 1 or 3 pixels to the left or the right. the most wiggle i see if the output changes from 9 to 10 numbers.
With this bug corona isn’t usable for my opinion. Anyone have an idea how can this be fixed ?
Thans in advanced
Klaus
[import]uid: 5456 topic_id: 7773 reply_id: 307773[/import]
yes tried it with ui.label ! same problem
2 spaces … is empty=" " a function ?
2 trailing spaces for one character doubles the spaces … tried it, no success [import]uid: 5456 topic_id: 7773 reply_id: 27818[/import]
if you use newText, then every time you set a new text, you have to reset the reference point and the x coordinate (which depends on the width of the text). that’s why i suggested the ui label
the third alternative, the native text box, cannot be inserted in a group…
i use this function to insert leading spaces:
local empty,characters=" ",10
local function leadingSpaces(n)
local str=tostring(n)
for i=1,characters-#str do
str=empty..str
end
return str
end
set the text param of the label equal to leadingSpaces(the_number_to_display)
it works OK for integers (though not pixel perfect), but i haven’t tried it with floats
and you don’t have to use courier, use any font you like
thanks for help, but this also doesn’t work. i tried ui.newLabel and newText, both have the same effect which you can see in the youtube video. ui.newLabel without static lenght its not so good as static lenght with leading spaces. compared display.newText with ui.newLabel there is no difference.
myText.text = "Number: "… myNumber --change the text
myText:setReferencePoint(display.TopLeftReferencePoint) --reset the display point
myText.x = 0 --redefine the position
The text now stays in the top-left corner.
note that in my example, the y coordinate did not change; only the x. This is because i did not change the size of my font; just the length of my string. [import]uid: 79674 topic_id: 7773 reply_id: 48004[/import]
Can you help me with my issue using the new text field? I am trying to do a subtraction problem and I want to type in the first number and then subtract the second number from that and display the answer below. This is my link to the other thread where this is going on. https://developer.anscamobile.com/forum/2011/08/08/text-field