avoid double backspace - #133
Conversation
Enable external text input sources like Superwhisper (speech-to-text) and the emoji picker to work with SDL windows. SDL doesn't natively support NSTextInputClient for accessibility-based input. The solution adds a transparent NSTextView overlay that: - Acts as first responder to receive accessibility queries - Forwards keyboard events to SDL for normal input - Intercepts Cmd+V to handle paste (used by Superwhisper) - Captures insertText: for emoji picker and keyboard input - Exposes accessibility attributes so apps can discover the text field
Both emoji picker and Superwhisper simulate Cmd+V after putting text on the pasteboard. The Cmd+V interception handles both cases, so the pasteboard check on window focus was causing double-paste and also incorrectly pasting clipboard contents when switching back to the app.
Issue: Backspace deletes two characters after adding accessibility paste/input support. Solution: Route SDL and accessibility text input through a shared handler. Filter backspace control bytes (0x08/0x7f) out of text payloads to avoid duplicate deletes. Document macOS accessibility input and backspace filtering behavior.
There was a problem hiding this comment.
Pull request overview
This PR implements macOS accessibility support to prevent duplicate backspace events when using external text input sources like emoji pickers and speech-to-text apps. The solution adds a hidden NSTextView that exposes proper accessibility attributes, keeps SDL text input active across focus changes, and filters backspace control bytes from text payloads to ensure deletion only occurs via keyboard events.
Changes:
- Added macOS-specific accessibility text input layer using Objective-C NSTextView with Zig wrapper
- Modified text input handling to keep SDL text input active across window focus changes
- Implemented backspace control byte filtering (0x08/0x7f) in text input processing
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/platform/sdl.zig | Added SDL text input area configuration function |
| src/platform/macos_text_input.zig | New Zig wrapper for macOS accessibility text input |
| src/platform/macos_text_input.m | New Objective-C implementation of accessible NSTextView |
| src/main.zig | Integrated accessibility input, removed focus-based text input toggling, added backspace filtering |
| src/c.zig | Added SDL3 property and text input area API bindings |
| docs/architecture.md | Documented backspace filtering behavior |
| build.zig | Added Objective-C source file compilation with ARC |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2558a64d6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Queue multiple text events using ArrayList instead of replacing - Add named constants for control characters (CTRL_BACKSPACE, CTRL_DELETE) - Add named constants for macOS text input (kTextViewAlpha, kKeyCodeV)
|
|
Closing this PR as stale rather than resolving the conflicts in place. The underlying macOS accessibility-input problem may still be worth revisiting, but this patch no longer maps cleanly onto the current architecture. Text input now lives in app/runtime.zig and app/input_text.zig, while the accessibility helper is not integrated into that runtime. The backspace change also needs a fresh reproduction and tests; the current ui/text_edit.zig path covers overlay fields, not necessarily terminal input. If the problem still exists, the best follow-up is a new focused PR against main, with manual coverage for emoji picker, Dictation/Superwhisper, IME composition, focus changes, paste/backspace behavior, and HiDPI text-input coordinates. |
Solution: