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

the KeyboardShortcut Recorder still gets the focus by default in certain cases #145

Closed
godbout opened this issue Aug 29, 2023 · 8 comments
Closed

Comments

@godbout
Copy link
Sponsor

godbout commented Aug 29, 2023

this doesn't happen when you first show your Settings dialog, but it happens at a later stage, if you start fingering the Recorder. this can be easily seen in the latest version of Plash. that will cause the issue reported in #144. see below:

ScreenFlow.mp4
@godbout
Copy link
Sponsor Author

godbout commented Sep 2, 2023

🙏️

@godbout
Copy link
Sponsor Author

godbout commented Sep 2, 2023

@sindresorhus still getting the issue for that one. (the closing the Settings window issue is fixed.) anything i can do to help troubleshoot?

@sindresorhus
Copy link
Owner

I'm unable to reproduce this with the latest version together with Plash. Are you able to reproduce in Plash?

If it's only reproducible in your app, can you try replacing b878f81#diff-41fc3abd80062ae3c8634038c89a3495bcd1d2455c1ff5cd5aa022f3409c6d8dR146-R149 with:

if #available(macOS 13, *) {
	Task {
		try? await Task.sleep(for: .seconds(0.5))
		canBecomeKey = true
	}
}

@godbout
Copy link
Sponsor Author

godbout commented Sep 2, 2023

will do in a couple of hours. will try the latest version of Plash, my apps, the replacement you propose, and may create a bare repo showing the issue if necessary. thanks.

@godbout
Copy link
Sponsor Author

godbout commented Sep 2, 2023

  1. i'm unable to reproduce on Plash either, it seems
  2. i've replace the code in RecorderCocoa by the snippet above, same thing, doesn't work in my apps
  3. if i just make canBecomeKey = false then everything works fine 😂️ (but haven't had dug yet about side effects

so i guess it's something in my apps. will dig. and will try to make a project from scratch and see.
also i'm on macOS 14, latest public beta if that matters. will work on latest macOS 13 tomorrow. also Plash is all good under macOS 14 so probably not the issue.

@godbout
Copy link
Sponsor Author

godbout commented Sep 2, 2023

dumping what i'm finding: if i show my Settings window from launching the app again, or through pressing command , on my input-à-la-Alfred, then the KeyboardShortcut doesn't take focus. but if i do through the status menu item it does. they all call the same static func of a class. so not sure what's going on 😂️

@godbout
Copy link
Sponsor Author

godbout commented Sep 3, 2023

i made a project from scratch with bare minimum code and the issue doesn't show up. so it has to be on my side. i'll try to figure out why, and i'll update here for reference. but as far as you're concerned, all is good on your side. thanks again Sindre!

@godbout
Copy link
Sponsor Author

godbout commented Sep 3, 2023

found it. it's coming from that func in my AppDelegates:

func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
    NSApp.hide(self)
        
    return false
}

for whatever reason this causes the issue with the KeyboardShortcuts Recorder. will see what i can do now from my side.

P.S.: this code is so that when closing the Settings of my apps, the focus goes back to the previous app rather than being in the limbo.

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

2 participants