Post

Replies

Boosts

Views

Activity

Comment on Disable a `contextMenu` button conditionally depending on the list item
Thanks for the answer! This doesn't immediately solves it but leads to more insights. Adding some print statement it seems that the onAppear and onChange is effectively acting on the Text(parent.name), not the contextMenu Button. .onChange does print differently upon children change, but then all list items is now sharing the same disableDelete. This approach won't work as it would require an array of disableDelete to track each Text(parent.name).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’24
Comment on Disable a `contextMenu` button conditionally depending on the list item
Thanks for the answer! This doesn't immediately solves it but leads to more insights. Adding some print statement it seems that the onAppear and onChange is effectively acting on the Text(parent.name), not the contextMenu Button. .onChange does print differently upon children change, but then all list items is now sharing the same disableDelete. This approach won't work as it would require an array of disableDelete to track each Text(parent.name).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’24
Comment on Disable a `contextMenu` button conditionally depending on the list item
.disabled(!parent.children.isEmpty) Only seems to capture the initial state. it doesn't enable/disable the button when parent.children is updated.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’24