Parameters
The menu items to display in the context menu. Typically contains Button components that define the menu actions.
Adds a context menu to the component that appears when the user performs a context menu gesture.
.contextMenu(content: Component): Component;
Text("Right-click me")
.contextMenu(
VStack([
Button("Copy", () => {
// Copy action
}),
Button("Paste", () => {
// Paste action
}),
Button("Delete", () => {
// Delete action
})
])
)
Image({ url: "photo.jpg" })
.contextMenu(
VStack([
Button("Edit", () => {
// Edit action
}),
Button("Share", () => {
// Share action
}),
Button("Delete", () => {
// Delete action
})
])
)
Text("Document")
.contextMenu(
VStack([
Button("Open", () => {
console.log("Opening document");
}),
Button("Duplicate", () => {
console.log("Duplicating document");
}),
Divider(),
Button("Move to Trash", () => {
console.log("Moving to trash");
})
])
)