1
Graphics / Re: Centering text on a rectangle not working
« on: November 06, 2020, 11:08:59 am »
In my case help this slightly modified solution, i just change this (textBounds.height / 2) to this textBounds.height
Code: [Select]
sf::FloatRect rectBounds = inputFieldRect_.getGlobalBounds();
sf::FloatRect textBounds = inputFieldText_.getGlobalBounds();
inputFieldText_.setPosition(
rectBounds.left + (rectBounds.width / 2) - (textBounds.width / 2),
rectBounds.top + (rectBounds.height / 2) - textBounds.height
);