Post

Replies

Boosts

Views

Activity

Can I display an Alert from a context menu?
I am currently trying to display an alert to the user when they click on an item from the context menu. It is currently not alerting. Below is my code and please ignore formatting since I did copy and paste. .toolbar { ToolbarItem(placement: .navigationBarTrailing) {       Menu(content: { Button("Disconnect") { showAlert = true                }                .alert(isPresented: $showAlert) {                  Alert( title: Text("Disconnect"),                           message: Text("Test."),                        primaryButton: .default(                            Text("Okay")                           ),                                secondaryButton: .destructive(Text("Cancel")                                )                            )                     }                     Button("Reboot") {                         // empty for now                   }                     Button("Factory Reset") {                         // empty for now                     }                 }, label: {Image(systemName: "ellipsis")})                     .foregroundColor(.black)                     .imageScale(.large)             }         }
1
0
2.0k
Oct ’21
Can I display an Alert from a context menu?
I am currently trying to display an alert to the user when they click on an item from the context menu. It is currently not alerting. Below is my code and please ignore formatting since I did copy and paste. .toolbar { ToolbarItem(placement: .navigationBarTrailing) {       Menu(content: { Button("Disconnect") { showAlert = true                }                .alert(isPresented: $showAlert) {                  Alert( title: Text("Disconnect"),                           message: Text("Test."),                        primaryButton: .default(                            Text("Okay")                           ),                                secondaryButton: .destructive(Text("Cancel")                                )                            )                     }                     Button("Reboot") {                         // empty for now                   }                     Button("Factory Reset") {                         // empty for now                     }                 }, label: {Image(systemName: "ellipsis")})                     .foregroundColor(.black)                     .imageScale(.large)             }         }
Replies
1
Boosts
0
Views
2.0k
Activity
Oct ’21