summaryrefslogtreecommitdiff
path: root/plugingui/lineedit.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-03-10 10:13:29 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-03-10 10:13:29 +0100
commit96c3915adeb68d1dd913d38431540eb52d43ff74 (patch)
tree471f6fce88dc042b704c94f039faf757d3155222 /plugingui/lineedit.cc
parenta6ddfd13f78d8f1a319cc997c81db90bf4b7b8f2 (diff)
Make cursor move at mouse click.
Diffstat (limited to 'plugingui/lineedit.cc')
-rw-r--r--plugingui/lineedit.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugingui/lineedit.cc b/plugingui/lineedit.cc
index c799e32..66d1e59 100644
--- a/plugingui/lineedit.cc
+++ b/plugingui/lineedit.cc
@@ -52,6 +52,19 @@ std::string GUI::LineEdit::text()
return _text;
}
+void GUI::LineEdit::buttonEvent(ButtonEvent *e)
+{
+ if(e->direction == 1) {
+ for(int i = 0; i < (int)_text.length(); i++) {
+ if(e->x < (int)(font.textWidth(_text.substr(0, i)) + BORDER)) {
+ pos = i;
+ break;
+ }
+ }
+ repaintEvent(NULL);
+ }
+}
+
void GUI::LineEdit::keyEvent(GUI::KeyEvent *e)
{
bool change = false;
@@ -108,7 +121,6 @@ void GUI::LineEdit::repaintEvent(GUI::RepaintEvent *e)
p.setColour(Colour(0, 0.4));
p.drawFilledRectangle(3,3,width()-3,height()-3);
- Font font;
p.setColour(Colour(1,1,1));
p.drawRectangle(0,0,width()-1,height()-1);
p.drawRectangle(2,2,width()-3,height()-3);