Good day!
I'm writing my TextBox so that the text does not go beyond the window, I use
glEnable(GL_SCISSOR_TEST);
glScissor(x, y, getSize().x, getSize().y);
window.draw(text);
glDisable(GL_SCISSOR_TEST);
But how do I use it if I have more than one window?
Good day!
I'm writing my TextBox so that the text does not go beyond the window, I use
glEnable(GL_SCISSOR_TEST);
glScissor(x, y, getSize().x, getSize().y);
window.draw(text);
glDisable(GL_SCISSOR_TEST);
But how do I use it if I have more than one window?
Do you want to input text even though it won't fit in the textbox or do you want to prevent the user from entering more text than what actually fits?
It's not really clear what you want to do and we are missing part of the code. Could you articulate better?
Class code (until the curve):
EditControl::EditControl(Font &_font, int x, int y, float _width, float _height)
{
font = &_font;
TextColor = Color(255,255,255);
CStandart = Color(27, 27, 28);
positionX = x;
positionY = y;
width = _width;
height = _height;
text.setFont(*font);
text.setCharacterSize(11);
text.setColor(TextColor);
text.setPosition(x + 4, y + 1);
SettingTheTextShift();//установка сдвига текста
Background.setPosition(x, y);
Background.setFillColor(CStandart);
Background.setSize(Vector2f(_width, _height + 1));//"+1"рамка
}
EditControl::~EditControl()
{
}
void EditControl::envent(sf::Event &event)
{
if (event.type == sf::Event::TextEntered)
{
m_newText = text.getString();
//Обработка ввода
switch ( event.text.unicode )
{
case 0xD: //Return
//m_newText += L'\n' ;
break ;
case 0x8://Backspace
if ( !m_newText.isEmpty() )
m_newText.erase(m_newText.getSize()-1) ;
break ;
default :
{
m_newText += static_cast<wchar_t>(event.text.unicode);
}
}
text.setString(m_newText);
SettingTheTextShift();//установка сдвига текста
}
}
void EditControl::draw(RenderWindow &window)
{
}
void EditControl::setTextColor(Color &color)
{
TextColor = color;
}
void EditControl::setCStandartColor(Color &color)
{
CStandart = color;
}
void EditControl::setTest(wchar_t *PText)
{
text.setString(PText);
SettingTheTextShift();
}
void EditControl::setTest(String &test)
{
text.setString(test);
SettingTheTextShift();
}
//private
void EditControl::SettingTheTextShift()
{
FloatRect Bounding_Rectangle(text.getLocalBounds());
int temp_width = (Bounding_Rectangle.width + 7);
if(temp_width > width)
{
temp_width = temp_width - width;
text.setPosition(positionX + 4 - temp_width, positionY + 1);
}
else
{
text.setPosition(positionX + 4, positionY + 1);
}
}
https://www.youtube.com/watch?v=-oV_5tt41fA&t
As far as I understand, these functions can determine the window themselves.
Can there be problems when used in multiple windows?