aboutsummaryrefslogtreecommitdiff
path: root/gui/widgets/edittext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/widgets/edittext.cpp')
-rw-r--r--gui/widgets/edittext.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index 0337fe1e87..4b266e8194 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -33,6 +33,7 @@ EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, cons
_finishCmd = finishCmd;
setEditString(text);
+ setFontStyle(ThemeEngine::kFontStyleNormal);
}
EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String &text, const char *tooltip, uint32 cmd, uint32 finishCmd)
@@ -42,6 +43,7 @@ EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String
_finishCmd = finishCmd;
setEditString(text);
+ setFontStyle(ThemeEngine::kFontStyleNormal);
}
void EditTextWidget::setEditString(const String &str) {
@@ -67,10 +69,13 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
int width = 0;
uint i;
+ uint last = 0;
for (i = 0; i < _editString.size(); ++i) {
- width += g_gui.theme()->getCharWidth(_editString[i], _font);
+ const uint cur = _editString[i];
+ width += g_gui.getCharWidth(cur, _font) + g_gui.getKerningOffset(last, cur, _font);
if (width >= x)
break;
+ last = cur;
}
if (setCaretPos(i))
draw();