Comments (6)
What macOS version is it?
Have you tried reproducing this in a new macOS app project with vanilla SwiftUI using just a window-based MenuBarExtra
and SettingsLink
? It would be useful to know if this is a SwiftUI issue or an issue related to the packages.
from settingsaccess.
I'm in macOS 14.0, Xcode target set to 14.0.
Yes, a brand new project using SwiftUI, window-based MenuBarExtra and SettingsLink.
It could be a SwiftUI issue. If this is the case, is it still possible to capture the Settings window using NSapp.windows
in some part of your package code, and try any of the solutions proposed? Something like:
for window in NSApp.windows {
if let windowId = window.identifier?.rawValue {
if windowId.contains("Settings") {
window.level = .floating // solution 1
window.becomeKey() // solution 2
}
}
}
from settingsaccess.
SettingsAccess is really just designed as a wrapper for Apple's SettingsLink
. If there's a quirk or bug with Apple's implementation it's best to report that with a radar of course.
I imagine you could shoehorn that code into the post-action closure of the custom SettingsLink
provided by the package. But it's brittle and may not cover all bases. It may be best left to the developer to solve this particular issue in that case.
from settingsaccess.
Still fighting with it.
I've tried multiple code alternatives in the post-action closure, but none worked out. I had some partial success, for example I was able to hide the minimise and maximise buttons of the Settings window, but no luck when trying to make it .floating
or set the focus calling makeKey()
or becomeKey()
. No worries, let's forget about this.
Then I came back to the original macControlCenterUI Demo app, and I realised that it does what I wanted. If I open the Settings from a fullscreen desktop, it leaves the fullscreen desktop and opens it in the main desktop setting the focus on it.
But creating a dummy sample project from scratch using both packages and doing same steps as macControlCenterUI Demo app does, I got different results. If I open the Settings from a fullscreen desktop, it doesn't leave the fullscreen desktop and opens it in the main desktop, without setting the focus on it.
Definitively I'm missing something but I can't find it.
import SwiftUI
import MenuBarExtraAccess
import SettingsAccess
@main
struct MenuBarPackagesApp: App {
@State var isMenuPresented: Bool = false
var body: some Scene {
Settings {
SettingsView()
}
MenuBarExtra("MyApp Menu", systemImage: "folder") {
MyMenu(isMenuPresented: $isMenuPresented)
.openSettingsAccess()
}
.menuBarExtraStyle(.window)
.menuBarExtraAccess(isPresented: $isMenuPresented) { statusItem in
// access status item or store it in a @State var
}
}
}
struct SettingsView: View {
var body: some View {
Text("Hello")
.frame(width: 300, height: 300)
}
}
struct MyMenu: View {
@Environment(\.openSettings) var openSettings
@Binding var isMenuPresented: Bool
var body: some View {
Button("Open settings") {
isMenuPresented = false
try? openSettings()
}
.frame(width: 200, height: 200)
}
}
from settingsaccess.
Oh man, I found it.
I wasn't setting the Target property "Application is agent (UIElement)"=YES
. For some reason that had a weird effect.
Doing that in fact opens the Settings window in the current fullscreen desktop. Whatever, that's good to me!
Let me thank you for your excellent work on these two packages, Steffan.
from settingsaccess.
Oh good! It's nice to find a simple resolution even if it takes time.
from settingsaccess.
Related Issues (6)
- `openSettings()` fails in menu-based MenuBarExtra HOT 9
- doesn't actually work programmatically (but this code does) HOT 13
- Current readme.md suggests minimum macOS is 11, this is wrong and should be 13 HOT 1
- macOS 14.4.1: Settings no longer orders front when activated HOT 3
- Error in macOS 15.0 Sequoia Beta HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from settingsaccess.