diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-20 19:41:38 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-20 19:41:38 (GMT) |
| commit | 1b75cbdcc93ebe63c4eae9e12107ce3ebf8ca7a6 (patch) | |
| tree | e9c71a6070d388372bf57b3806bcbeb1b39fa9ac /src/interface | |
| parent | 8e43ee60bbca41ab420712eb723a37770bfe062e (diff) | |
| download | powder-1b75cbdcc93ebe63c4eae9e12107ce3ebf8ca7a6.zip powder-1b75cbdcc93ebe63c4eae9e12107ce3ebf8ca7a6.tar.gz | |
Limit on text width in textboxes
Diffstat (limited to 'src/interface')
| -rw-r--r-- | src/interface/Textbox.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp index 341e4f5..57f9a26 100644 --- a/src/interface/Textbox.cpp +++ b/src/interface/Textbox.cpp @@ -361,7 +361,10 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool 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()) { @@ -371,8 +374,8 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool { backingText.insert(cursor, 1, (char)character); } + cursor++; } - cursor++; changed = true; ClearSelection(); } |
