Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make keyboard focus a compile time macro #415

Open
dromer opened this issue Mar 7, 2023 · 6 comments
Open

Make keyboard focus a compile time macro #415

dromer opened this issue Mar 7, 2023 · 6 comments

Comments

@dromer
Copy link
Contributor

dromer commented Mar 7, 2023

As discussed on IRC. Forcing focus may not always be wanted.

@MattKuebrich
Copy link

MattKuebrich commented Jan 22, 2024

I think this is the same issue I came to report.

When the plugin UI is selected, it blocks the keyboard presses from being sent to the DAW. For example, you can't hit spacebar to start the timeline or use the computer keyboard to play notes, etc. That's usually not ideal, so I'd support an option to disable this as well.

For Mac, I was able to accomplish this by switching acceptsFirstResponder to NO in mac.m

@falkTX
Copy link
Contributor

falkTX commented Jan 22, 2024

DPF does not do automatic focus, the ticket is to add some way for plugins to request it. The DPF stealing keyboard input from the DAW is likely due to something "returning true" for keyboard events, and thus not having them propagate on the OS level anymore. But this varies wildly between hosts, there is no consistency afaik

@MattKuebrich
Copy link

Ah okay, sorry for jumping in on the wrong issue. I don't totally understand the original ticket (I assume dromer wants to use the keyboard to control his plugin?), but thanks for the info about DPF stealing focus. You're right about different hosts - the acceptsFirstResponder fix above works in Bitwig, but not in Ableton Live (on MacOS). Thanks for your help. This stuff sure is fiddly!

@dromer
Copy link
Contributor Author

dromer commented Jan 22, 2024

I actually don't remember what this was about, I created the ticket as a result from a discussion on IRC.

Could've put some more context to remember -_-

@lucianoiam
Copy link
Contributor

Try this for Live on Mac

- (void)keyDown:(NSEvent *)event
{
    if (shouldMyPluginConsumeKeystrokes) {
        [super keyDown:event];
    } else {
        [self.superview keyDown:event];
    }
}

self.superview might be self.superview.superview depending the view hierarchy

Repeat for keyUp and flagsChanged

It might be worth checking what JUCE does about this.

@MattKuebrich
Copy link

Thank you!

Before I saw your message I tried adding this to mac.m and it seems to be working (not blocking the keyboard) in Ableton Live, Bitwig and Reaper on MacOS.

- (BOOL) becomeFirstResponder
{
    BOOL ret = [self acceptsFirstResponder];
    return ret;
}
- (BOOL) resignFirstResponder
{
    BOOL ret = [self acceptsFirstResponder];
    return ret;
}

I found that from this JUCE thread.

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

No branches or pull requests

4 participants