diff --git a/src/silky/internal/inputs.nim b/src/silky/internal/inputs.nim index 4f248ec4..cc36c37d 100644 --- a/src/silky/internal/inputs.nim +++ b/src/silky/internal/inputs.nim @@ -334,6 +334,9 @@ proc takeInput*(inputs: TextInputs): seq[InputEvent] = proc endInputFrame*(inputs: TextInputs, window: Window) = ## Ends capture when the active field was not submitted this frame. + if not inputs.active: + # The application can use the window's text input between Silky fields. + return if not inputs.submitted: inputs.stopInput(window) elif inputs.editable and inputs.pendingText.id == inputs.id: diff --git a/tests/test_inputs.nim b/tests/test_inputs.nim index 0bdc2742..18f0e506 100644 --- a/tests/test_inputs.nim +++ b/tests/test_inputs.nim @@ -187,6 +187,22 @@ block: f.frame() doAssert not f.state.focused and f.text == "R" +block: + echo "Testing application text capture across Silky frames" + var + received = "" + f = fixture(onRune = proc(rune: Rune) = received.add($rune)) + let + window = f.harness.window + chat = TextInputState(id: "chat", text: "Hello") + window.runeInputEnabled = true + window.setTextInputState(chat) + for visible in [false, true, false]: + f.frame(visible = visible) + doAssert window.runeInputEnabled and window.textInput == chat + window.typeRune(Rune('x')) + doAssert received == "xxx" + block: echo "Testing keyboard consumption and callback holds during text entry" var