I would like to create a menu that has a dynamic content (very easy to do), but I would like to sort them if the option-key was pressed when the menu was clicked. I have explored using gestures, but I can’t figure out how to change my state from the gesture in a way that won’t interfere with the operation of the menu itself.
Is there a way to update a State variable based on tap+modifier key, that will occur before the menu subviews are created, and won’t interfere with the normal operation of the menu?
This is for MacOS, thanks!
Menu("My Menu") {
if <option-key pressed?> {
// sorted order
Button("A") { }
Button("B") { }
Button("C") { }
Button("D") { }
} else {
// natural order
Button("B") { }
Button("D") { }
Button("A") { }
Button("C") { }
}
}