diff options
| -rw-r--r-- | plugingui/lineedit.cc | 14 | ||||
| -rw-r--r-- | plugingui/lineedit.h | 8 | 
2 files changed, 19 insertions, 3 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); diff --git a/plugingui/lineedit.h b/plugingui/lineedit.h index f85b7ae..46fa5bc 100644 --- a/plugingui/lineedit.h +++ b/plugingui/lineedit.h @@ -31,6 +31,7 @@  #include <string>  #include "widget.h" +#include "font.h"  namespace GUI { @@ -44,13 +45,16 @@ public:    void setText(std::string text);    //protected: -  void keyEvent(KeyEvent *e); -  void repaintEvent(RepaintEvent *e); +  virtual void keyEvent(KeyEvent *e); +  virtual void repaintEvent(RepaintEvent *e); +  virtual void buttonEvent(ButtonEvent *e);  protected:    virtual void textChanged() {}  private: +  Font font; +    std::string _text;    size_t pos;  }; | 
