Skip to content

feat: add focus handling to macOS view for proper key event forwarding#203

Closed
andrewrynhard wants to merge 1 commit intoRustAudio:masterfrom
andrewrynhard-audio:focus
Closed

feat: add focus handling to macOS view for proper key event forwarding#203
andrewrynhard wants to merge 1 commit intoRustAudio:masterfrom
andrewrynhard-audio:focus

Conversation

@andrewrynhard
Copy link
Copy Markdown

@andrewrynhard andrewrynhard commented Mar 17, 2025

Updated the add_mouse_button_class_method! macro.
Now, when $foc is true, the code calls makeFirstResponder on the window to ensure the view becomes the first responder.
This change enables the plugin view to properly capture keyboard input on macOS.

Credit to @justinfrankel. See #202.

Updated the `add_mouse_button_class_method!` macro.
Now, when `$foc` is true, the code calls `makeFirstResponder` on the window to ensure the view becomes the first responder.
This change enables the plugin view to properly capture keyboard input on macOS.
@andrewrynhard
Copy link
Copy Markdown
Author

Fixes #191.

@andrewrynhard
Copy link
Copy Markdown
Author

While we are at it, I believe I am seeing the same issue in Windows. Is that expected? Where would I look if I wanted to fix that?

@kronihias
Copy link
Copy Markdown

kronihias commented Apr 12, 2026

This fixes keyboard focus for plugins within Reaper for me (eg. a textfield).

Any chance we can get this merged?

@micahrj
Copy link
Copy Markdown
Member

micahrj commented Apr 12, 2026

This is unnecessary. There is already a Window::focus method which calls makeFirstResponder on macOS, which applications can call explicitly e.g. in response to mouse down events:

pub fn focus(&mut self) {
unsafe {
let view = self.inner.ns_view.as_mut().unwrap();
let window: id = msg_send![view, window];
if window != nil {
msg_send![window, makeFirstResponder:view]
}
}
}

@micahrj micahrj closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants