Post

Replies

Boosts

Views

Activity

Reply to Drag and Drop in Nested List
Okay, well, ahem. I got this to work with a List. I always understood that would not work, that I would have to use ForEach to access the hierarchical sidebar list I need by using a list. The issue was my Model data class (Sidebar) gave it indigestion. There were NO error messages; there was NO crash. It simply hung. No memory leaks, and I could find nowhere to place a breakpoint - it was basically contemplating its the navel. I finally fixed it by dragging only the sidebar.id (a uuidString) and then doing an "if let sidebar = sidebars. first(where: {$0.id == items[0]}) { print(sidebar.title) }" in the destination. Here is my List for those who might be struggling with doing this: List(sidebars.sorted{$0.index < $1.index}[0].children!, id:\.id, children: \.children, selection: $selected) { sidebar in NavigationLink { SidebarDetailSelectorView(sidebar: sidebar) } label: { rowLabel(sidebar: sidebar) //.background(Color.random()) } .onChange(of: selected) { current.sidebar = sidebars.first{ $0.id == selected } } .draggable(sidebar.id) .dropDestination(for: UUID.self) { items, location in if let sidebar = sidebars.first(where: {$0.id == items[0]}) { print(sidebar.title) // do magic here... } return true } isTargeted: { isTargeted in sidebar.isTargeted = isTargeted } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’23
Reply to NSFontPanel in SwiftUI
To clarify, regardless of what color I select in the FontPanel it returns ["NSForegroundColorAttributeName": Catalog color: System textColor, "NSColor": Catalog color: System textColor] Catalog color: System textColor ["NSForegroundColorAttributeName": Catalog color: System textColor, "NSColor": Catalog color: System textColor] Catalog color: System textColor
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22