diff options
author | Willem Jan Palenstijn | 2006-05-27 13:17:19 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2006-05-27 13:17:19 +0000 |
commit | 0993c6a712fa76cd2cd43a066489781dece7161a (patch) | |
tree | d4b114d07c6aae7c0d343ae599504efc6dd7df7f /gui | |
parent | 1da221279cac046e6aadf05d75fbdf21b643cfab (diff) | |
download | scummvm-rg350-0993c6a712fa76cd2cd43a066489781dece7161a.tar.gz scummvm-rg350-0993c6a712fa76cd2cd43a066489781dece7161a.tar.bz2 scummvm-rg350-0993c6a712fa76cd2cd43a066489781dece7161a.zip |
make EditableWidget's caret visible when it moves
svn-id: r22682
Diffstat (limited to 'gui')
-rw-r--r-- | gui/editable.cpp | 16 | ||||
-rw-r--r-- | gui/editable.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/gui/editable.cpp b/gui/editable.cpp index 208383fe4b..3da679d0e1 100644 --- a/gui/editable.cpp +++ b/gui/editable.cpp @@ -80,6 +80,7 @@ void EditableWidget::handleTickle() { bool EditableWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { bool handled = true; bool dirty = false; + bool forcecaret = false; // First remove caret if (_caretVisible) @@ -102,33 +103,40 @@ bool EditableWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { _editString.deleteChar(_caretPos); dirty = true; } + forcecaret = true; break; case 127: // delete _editString.deleteChar(_caretPos); + forcecaret = true; dirty = true; break; case 256 + 20: // left arrow if (_caretPos > 0) { dirty = setCaretPos(_caretPos - 1); } + forcecaret = true; dirty = true; break; case 256 + 19: // right arrow if (_caretPos < (int)_editString.size()) { dirty = setCaretPos(_caretPos + 1); } + forcecaret = true; dirty = true; break; case 256 + 22: // home dirty = setCaretPos(0); + forcecaret = true; break; case 256 + 23: // end dirty = setCaretPos(_editString.size()); + forcecaret = true; break; default: if (tryInsertChar((char)ascii, _caretPos)) { _caretPos++; dirty = true; + forcecaret = true; } else { handled = false; } @@ -137,6 +145,9 @@ bool EditableWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { if (dirty) draw(); + if (forcecaret) + makeCaretVisible(); + return handled; } @@ -207,5 +218,10 @@ bool EditableWidget::adjustOffset() { return false; } +void EditableWidget::makeCaretVisible() { + _caretTime = getMillis() + kCaretBlinkTime; + _caretVisible = true; + drawCaret(false); +} } // End of namespace GUI diff --git a/gui/editable.h b/gui/editable.h index 4cc087b1fa..9236c96165 100644 --- a/gui/editable.h +++ b/gui/editable.h @@ -72,6 +72,7 @@ protected: void drawCaret(bool erase); bool setCaretPos(int newPos); bool adjustOffset(); + void makeCaretVisible(); void setFontStyle(Theme::kFontStyle font) { _font = font; } |