Post

Replies

Boosts

Views

Activity

Reply to Button text is invisible after dark/light mode change
JoshATA, It appears that the HSplitView is causing it. If you run the following, and change light to dark or vice versa in System Preferences, you see the "Test" button behave badly. struct ContentView: View {     var body: some View {         HSplitView {                        VStack {                 Text("Does this button change color correctly?")                 Button("Test") {                     print("Hi.")                 }             }         }         .frame(maxWidth: .infinity, maxHeight: .infinity)     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Button text is invisible after dark/light mode change
Hi "workingdogintokyo", Thanks for taking the time to do that. I'm running the newest non-beta stuff: macOS 11.2.1 and Xcode 12.4. So maybe that's the difference, and they've fixed it in the new versions. One other thing I didn't mention: I checked "SwiftUI App" when creating my test project, not "AppKit App Delegate". Other than that I changed nothing, besides the ContentView code I posted. I may also try a system restart. My MacBook's current "uptime" is 36 days.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Refresh @CommandsBuilder to update menu bar items
I'm seeing a similar problem. I'm trying to change the CommandGroup Buttons based to some state in an ObservableObject, and it's not happening. Did you ever figure this out? As you said, uses include: Showing a checkmark for boolean states, like "✓ Foo enabled" Items that show or hide parts of view. Eg, "Show Sidebar" ↔︎ "Hide Sidebar" Enabling or disabling items
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to How to Create a Searchable Help Book with Help Indexer?
It's obnoxious isn't it. What did you end up doing? I'm thinking of a few options... Include HTML in bundle, display in WKWebView within my app. Include HTML in bundle, send user to web browser to view. Include a PDF in bundle, send user to Preview or whatever to view it. Try a Help Book, even though the docs are 8 years old and I see lots of confusing posts online about it.
Topic: App & System Services SubTopic: Core OS Tags:
Mar ’21
Reply to Refresh @CommandsBuilder to update menu bar items
I don't know if this is a bug or what, but here is something that works. Add a level of indirection. Example: struct MyApp: App { @StateObject var appModel: AppModel = .init() ...     var body: some Scene {       WindowGroup { ... }.commands { CommandGroup(after: CommandGroupPlacement.toolbar) {     ItemsThatUpdate().environmentObject(appModel) } } ... struct ItemsThatUpdate: View {     @EnvironmentObject var appModel: AppModel     var body: some View {         Group {             Button(action: toggleFoo) { // Now this text will update as desired when model changes                 Text(verbatim: "Toggle Foo - \(appModel.foo)")             }             Button ... Button ...         }     }     private func toggleFoo() {         appModel.foo.toggle()     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Looking for opinions - Math Tables in a List
Are you asking how to generate the list dynamically? Here is one way below. You can't have a for loop directly in the body of a SwiftUI view. Maybe in the future, but for now you have to use the ForEach thing. func makeTables() - [String] {     var result = ["Temporary"]     for i in 1...20 {         result.append("\(i) + \(i) = \(i+i)")     }     return result } struct ContentView: View {     var tables: [String] = makeTables()     var body: some View {         NavigationView {             List {                 ForEach(self.tables, id: \.self) { show in                     HStack {                         Image(systemName: "arrow.right")                             .resizable()                             .frame(width: 30, height: 20, alignment: .center)                         Text(show)                             .font(.custom("Chalkboard", size: 50))                     }                 }             }.navigationBarTitle(Text("Addition Tables (1 - 20)"))             .navigationBarTitleDisplayMode(.inline)         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Differentiating between "return" and focus loss in TextField onCommit
Sorry, I don't follow. There is no action: parameter for TextField, so what is would get triggered by the keyboard shortcut? I tried putting the modifier on it anyway, but the behavior is the same. TextField("Search", text: $searchQuery) { editing in .... } onCommit: { ... // still triggered by return OR focus loss }.keyboardShortcut(.defaultAction) I ended up using NSViewRepresentable and wrapping an NSTextField. So I have something working now, but I'd prefer to use pure SwiftUI if I can.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21