Post

Replies

Boosts

Views

Activity

Reply to macOS SwiftUI Table with contextMenu
Here's how to ensure that the hitbox for the context menu extends across the entire cell for all cells in the table view: Text("Item at \($0.name!)")   .frame(     maxWidth: .infinity,     maxHeight: .infinity,     alignment: .leading   )   .contentShape(Rectangle())   .contextMenu {     Button(action: {}) { Text("Action 1") }     Divider()     Button(action: {}) { Text("Action 2") }     Button(action: {}) { Text("Action 3") }   }
Mar ’22
Reply to How to implement the right detail panel by swiftUI?
NavigationView {   Text("sidebar")   HSplitView {     Text("Primary View")       .frame(maxWidth: .infinity, maxHeight: .infinity)       .background(.blue)       .layoutPriority(1)     Text("Detail Panel")       .frame(maxWidth: .infinity, maxHeight: .infinity)       .background(.red)   } }
Feb ’22
Reply to How to implement the right detail panel by swiftUI?
Try this: NavigationView {   Text("sidebar")   HSplitView {     Text("Primary View")       .frame(maxWidth: .infinity, maxHeight: .infinity)       .background(.blue)     Text("Detail Panel")       .frame(maxWidth: .infinity, maxHeight: .infinity)       .background(.red)   } } The background colors aren't even necessary. They just allow you to better visualize the bounds of each section of the HSplitView.
Feb ’22
Reply to How to create proper array time at runtime in Swift
If you don't know the types of the array's elements in the "channel" at compile-time, then I would recommend that you convert them to the widest number type among all of the possible types in the channel. For example, if the channel could contain Int32 or Int64 number types, then your array in Swift should always contain elements of type Int64, because this is the wider type. Just convert values of type Int32 to Int64 when initializing the Swift array from the channel data.
Feb ’22