Post

Replies

Boosts

Views

Activity

Identify front window in document-based Mac app
I have a document-based Mac app using the SwiftUI life-cycle. It works well except that I cannot work out how to tell which window is frontmost. So if I have a menu item that operates on a document, how can I apply it to the document in the frontmost window? Any approach using notifications or passthrough subjects gets applied to all open windows. I think that the focusable modifiers are supposed to deal with this, but they do not appear to work.
0
0
531
Aug ’20
Mac Big Sur app with sidebar clears NavigationLink view
I have a simple test app with a list of items in a NavigationView List. When one is clicked, it fills in the data in a detail view called by a NavigationLink. If the app goes to the background, or the sidebar is completely collapsed, the detail view disappears. I see that it calls the view's onDisppear modifier. This does not happen with macOS Catalina but happens with Big Sur when using Xcode 12 with the new SwiftUI App lifecycle or Xcode 11 with the old UIKit life cycle. I have tried creating a state object that stores the selection, binding the selection in the NavigationLink and lots of other options, but I cannot work out how to persist the detail view. The Fruta sample app does this fine, but there is so much else going on there, that I cannot work out what bit is making this work. Any ideas?
1
0
889
Jun ’20