From 161cdd65c62b0d96dff37bbc20379bc4c3bbd6e3 Mon Sep 17 00:00:00 2001 From: Jacalz Date: Sat, 22 Jul 2023 12:04:57 +0200 Subject: [PATCH] Add testing code for backspace + ctrl in entry --- widget/entry_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/widget/entry_test.go b/widget/entry_test.go index d8d26d31fc..ed864a5098 100644 --- a/widget/entry_test.go +++ b/widget/entry_test.go @@ -197,6 +197,21 @@ func TestEntry_Control_Word(t *testing.T) { // unselect when no shift press entry.TypedShortcut(nextWord) assert.Equal(t, "", entry.SelectedText()) + + // delete word when pressing backspace + deleteWord := &desktop.CustomShortcut{KeyName: fyne.KeyBackspace, Modifier: fyne.KeyModifierShortcutDefault} + entry.SetText("word1 word2 word3") + entry.TypedShortcut(deleteWord) + assert.Equal(t, "word1 word2 ", entry.Text) + entry.TypedShortcut(deleteWord) + assert.Equal(t, "word1 ", entry.Text) + entry.TypedShortcut(deleteWord) + assert.Equal(t, "", entry.Text) + + // Deleting with nothing to delete does nothing + entry.TypedShortcut(deleteWord) + assert.Equal(t, "", entry.Text) + } func TestEntry_CursorColumn_Wrap(t *testing.T) {