diff options
author | Joel Bodenmann <joel@seriouslyembedded.com> | 2015-08-14 18:53:05 +0200 |
---|---|---|
committer | Joel Bodenmann <joel@seriouslyembedded.com> | 2015-08-14 18:53:05 +0200 |
commit | 2c99e8c6869c8786e7c2ce95f2af82acf0831141 (patch) | |
tree | 82ebb0f22c8c2f92879dc3de27f7e2e98b518beb /src/gwin/gwin_textedit.c | |
parent | b828bf567bd6989cddb3259a65871f7460011f5d (diff) | |
download | uGFX-2c99e8c6869c8786e7c2ce95f2af82acf0831141.tar.gz uGFX-2c99e8c6869c8786e7c2ce95f2af82acf0831141.tar.bz2 uGFX-2c99e8c6869c8786e7c2ce95f2af82acf0831141.zip |
Adding handler for the DELETE button to the TextEdit widget
Diffstat (limited to 'src/gwin/gwin_textedit.c')
-rw-r--r-- | src/gwin/gwin_textedit.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gwin/gwin_textedit.c b/src/gwin/gwin_textedit.c index 999a91dd..8f5cb8dd 100644 --- a/src/gwin/gwin_textedit.c +++ b/src/gwin/gwin_textedit.c @@ -86,7 +86,7 @@ static void _shiftTextRight(char* buffer, size_t bufferSize, size_t index, char // Parse the key press else if (pke->bytecount >= 1) { - // Check backspace + // Is it backspace? if (pke->c[0] == GKEY_BACKSPACE) { if (gw2obj->cursorPos == 0) { return; @@ -94,6 +94,15 @@ static void _shiftTextRight(char* buffer, size_t bufferSize, size_t index, char _shiftTextLeft(gw2obj->textBuffer, gw2obj->bufferSize, gw2obj->cursorPos--); } + // Is it delete? + else if (pke->c[0] == GKEY_DEL) { + // Check whether there is a character on the right side of the cursor + if (gw2obj->textBuffer[gw2obj->cursorPos] == '\0') { + return; + } + _shiftTextLeft(gw2obj->textBuffer, gw2obj->bufferSize, gw2obj->cursorPos+1); + } + // Add a new character else { // Shift everything right from the cursor by one character. This includes the '\0'. Then inser the new character. |