From 96c3915adeb68d1dd913d38431540eb52d43ff74 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 10 Mar 2013 10:13:29 +0100 Subject: Make cursor move at mouse click. --- plugingui/lineedit.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'plugingui/lineedit.cc') 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); -- cgit v1.2.3