aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMax Horn2003-05-05 16:12:45 +0000
committerMax Horn2003-05-05 16:12:45 +0000
commit3468e2caab01027da3743dd1a49fb9bdbd9462fd (patch)
tree632cc1a070d62790d2752d7712b8645ba09d050a /gui
parent898387e1ac906af80f7ee459306e75743c37a75a (diff)
downloadscummvm-rg350-3468e2caab01027da3743dd1a49fb9bdbd9462fd.tar.gz
scummvm-rg350-3468e2caab01027da3743dd1a49fb9bdbd9462fd.tar.bz2
scummvm-rg350-3468e2caab01027da3743dd1a49fb9bdbd9462fd.zip
Patch #732725: EditTextWidget: handleMouseDown positions caret
svn-id: r7360
Diffstat (limited to 'gui')
-rw-r--r--gui/EditTextWidget.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp
index 4ead9a73d6..17a4abc3f6 100644
--- a/gui/EditTextWidget.cpp
+++ b/gui/EditTextWidget.cpp
@@ -51,9 +51,26 @@ void EditTextWidget::handleTickle() {
}
}
-void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
- // TODO - once we support "real editing" (i.e. caret can be at any spot),
- // a mouse click should place the caret.
+void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount){
+ // First remove caret
+ if (_caretVisible)
+ drawCaret(true);
+
+ NewGui *gui = _boss->getGui();
+
+ x += _labelOffset;
+
+ int width = 0;
+ int i;
+
+ for (i = 0; i < _label.size(); ++i) {
+ width += gui->getCharWidth(_label[i]);
+ if (width >= x)
+ break;
+ }
+ _pos = i;
+ if (adjustOffset())
+ draw();
}
bool EditTextWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) {