Impose limit when pasting into textboxes
This commit is contained in:
parent
d78082d368
commit
39afea3945
@ -206,6 +206,29 @@ void Textbox::pasteIntoSelection()
|
|||||||
*iter = '0';
|
*iter = '0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int regionWidth = Size.X;
|
||||||
|
if(Appearance.icon)
|
||||||
|
regionWidth -= 13;
|
||||||
|
regionWidth -= Appearance.Margin.Left;
|
||||||
|
regionWidth -= Appearance.Margin.Right;
|
||||||
|
|
||||||
|
if(limit!=std::string::npos)
|
||||||
|
{
|
||||||
|
if(limit-backingText.length() > 0)
|
||||||
|
newText.substr(0, limit-backingText.length());
|
||||||
|
}
|
||||||
|
else if(Graphics::textwidth((char*)std::string(backingText+newText).c_str()) > regionWidth)
|
||||||
|
{
|
||||||
|
int pLimit = regionWidth - Graphics::textwidth((char*)backingText.c_str());
|
||||||
|
int cIndex = Graphics::CharIndexAtPosition((char *)newText.c_str(), pLimit, 0);
|
||||||
|
|
||||||
|
if(cIndex > 0)
|
||||||
|
newText = newText.substr(0, cIndex);
|
||||||
|
else
|
||||||
|
newText = "";
|
||||||
|
}
|
||||||
|
|
||||||
backingText.insert(cursor, newText);
|
backingText.insert(cursor, newText);
|
||||||
cursor = cursor+newText.length();
|
cursor = cursor+newText.length();
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
|
Reference in New Issue
Block a user