Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions runtime/src/ceramic/EditText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,29 @@ class EditText extends Entity implements Component implements TextInputDelegate
emitUpdate(newText);
});

keyBindings.bind([KEY(KeyCode.DELETE)], function() {
// Delete key
if (screen.focusedVisual != entity)
return;

var newText = '';
if (selectText.selectionStart != selectText.selectionEnd) {
newText = entity.content.substring(0, selectText.selectionStart) + entity.content.substring(selectText.selectionEnd);
selectText.selectionEnd = selectText.selectionStart;
} else {
if (selectText.selectionStart < entity.content.length) {
newText = entity.content.substring(0, selectText.selectionStart) + entity.content.substring(selectText.selectionStart + 1);
} else {
return;
}
}

// Update text content
entity.content = newText;
app.textInput.text = newText;
emitUpdate(newText);
});

onDestroy(keyBindings, function(_) {
keyBindings.destroy();
keyBindings = null;
Expand Down