49 | | void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) { |
50 | | // TODO - once we support "real editing" (i.e. caret can be at any spot), |
51 | | // a mouse click should place the caret. |
| 54 | void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount){ |
| 55 | // First remove caret |
| 56 | if (_caretVisible) |
| 57 | drawCaret(true); |
| 58 | |
| 59 | NewGui *gui = _boss->getGui(); |
| 60 | |
| 61 | x += _labelOffset; |
| 62 | |
| 63 | int width = 0; |
| 64 | int i; |
| 65 | |
| 66 | for (i = 0; i < _label.size(); ++i) { |
| 67 | width += gui->getCharWidth(_label[i]); |
| 68 | if (width >= x) |
| 69 | break; |
| 70 | } |
| 71 | _pos = i; |
| 72 | if (adjustOffset()) |
| 73 | draw(); |