Adding handler for the DELETE button to the TextEdit widget
This commit is contained in:
parent
b828bf567b
commit
2c99e8c686
1 changed files with 10 additions and 1 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue