ymobe/rapanui

Setting x and y of RNText is setting top left corner of textbox not the center of the text field like everything else

Opened this issue · 1 comments

Most objects have x, y as the center however RNText is using the top left corner of the textbox when set. For example the following code should make the text be centered at the bottom right corner of the screen but instead it is near the middle:

local clickOnTheScreen = RNFactory.createText("Click on the screen", { size = 30, top = 0, left = 0, width = 200, height = 60 })
clickOnTheScreen.x = RNFactory.width/2.0;
clickOnTheScreen.y = RNFactory.height/2.0;

As a side note it would be nice to figure out the width of the top, left, width and height for the user (though I know this is not easy.

Yes,

RNTexts don't work as other regular RNObjects regarding coordinates.
You have to practice a little bit with them, at the moment , but it would be nice to have their coordinates to work exactly as a regular RNObject.

Also, you are right, at the moment width and height are not stored in RNTexts as accessible values to the user. This could be a fast / one line improvement.

Thanks for the issue.