aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@seriouslyembedded.com>2015-08-14 18:53:05 +0200
committerJoel Bodenmann <joel@seriouslyembedded.com>2015-08-14 18:53:05 +0200
commit2c99e8c6869c8786e7c2ce95f2af82acf0831141 (patch)
tree82ebb0f22c8c2f92879dc3de27f7e2e98b518beb
parentb828bf567bd6989cddb3259a65871f7460011f5d (diff)
downloaduGFX-2c99e8c6869c8786e7c2ce95f2af82acf0831141.tar.gz
uGFX-2c99e8c6869c8786e7c2ce95f2af82acf0831141.tar.bz2
uGFX-2c99e8c6869c8786e7c2ce95f2af82acf0831141.zip
Adding handler for the DELETE button to the TextEdit widget
-rw-r--r--src/gwin/gwin_textedit.c11
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.