From c178fa35a2e982f250248c0198d200e951ba4ead Mon Sep 17 00:00:00 2001 From: myk002 Date: Mon, 29 Aug 2022 11:49:12 -0700 Subject: [PATCH] unit test EditField ignore_keys --- test/library/gui/widgets.EditField.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/library/gui/widgets.EditField.lua b/test/library/gui/widgets.EditField.lua index 15acfddb0..23558987b 100644 --- a/test/library/gui/widgets.EditField.lua +++ b/test/library/gui/widgets.EditField.lua @@ -54,3 +54,18 @@ function test.editfield_click() expect.eq(3, e.cursor) end) end + +function test.editfield_ignore_keys() + local e = widgets.EditField{ignore_keys={'CUSTOM_B', 'CUSTOM_C'}} + e:setFocus(true) + + e:onInput{_STRING=string.byte('a'), CUSTOM_A=true} + expect.eq('a', e.text, '"a" should be accepted') + e:onInput{_STRING=string.byte('b'), CUSTOM_B=true} + expect.eq('a', e.text, '"b" should be rejected') + e:onInput{_STRING=string.byte('c'), CUSTOM_C=true} + expect.eq('a', e.text, '"c" should be rejected') + e:onInput{_STRING=string.byte('d'), CUSTOM_D=true} + expect.eq('ad', e.text, '"d" should be accepted') + +end