Limit on text width in textboxes
This commit is contained in:
parent
8e43ee60bb
commit
1b75cbdcc9
@ -361,7 +361,10 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
cursor = getLowerSelectionBound();
|
cursor = getLowerSelectionBound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(limit==std::string::npos || backingText.length() < limit)
|
int regionWidth = Size.X;
|
||||||
|
if(Appearance.icon)
|
||||||
|
regionWidth -= 17;
|
||||||
|
if((limit==std::string::npos || backingText.length() < limit) && (Graphics::textwidth((char*)std::string(backingText+char(character)).c_str()) <= regionWidth || multiline || limit!=std::string::npos))
|
||||||
{
|
{
|
||||||
if(cursor == backingText.length())
|
if(cursor == backingText.length())
|
||||||
{
|
{
|
||||||
@ -371,8 +374,8 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
{
|
{
|
||||||
backingText.insert(cursor, 1, (char)character);
|
backingText.insert(cursor, 1, (char)character);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
cursor++;
|
cursor++;
|
||||||
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ void PreviewView::commentBoxAutoHeight()
|
|||||||
if(!addCommentBox)
|
if(!addCommentBox)
|
||||||
return;
|
return;
|
||||||
int textWidth = Graphics::textwidth(addCommentBox->GetText().c_str());
|
int textWidth = Graphics::textwidth(addCommentBox->GetText().c_str());
|
||||||
if(textWidth+5 > Size.X-(XRES/2)-48)
|
if(textWidth+10 > Size.X-(XRES/2)-48)
|
||||||
{
|
{
|
||||||
commentBoxHeight = 59;
|
commentBoxHeight = 59;
|
||||||
addCommentBox->SetMultiline(true);
|
addCommentBox->SetMultiline(true);
|
||||||
|
Reference in New Issue
Block a user