Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/silky/internal/inputs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_inputs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading