title: How to change content of SwiftUI menu if option was pressed during tap
body: <p>I would like to create a SwiftUI Menu that has a dynamic content (very easy to do), but I would like to sort the items 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.</p>
  <p>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?</p>
  <p>The Menu will have “recents” and might contain a few dozen entries.  Being able to sort the history will make it faster to find a specific entry.  I want to use a Menu because it’s very compact when not engaged.</p>
  <p>The skeleton of what I am looking for is:</p>
  <pre><code>Menu(&quot;My Menu&quot;) {
      if &lt;option-key pressed?&gt; {
          // sorted  order
          Button(&quot;A&quot;) { }
          Button(&quot;B&quot;) { }
          Button(&quot;C&quot;) { }
          Button(&quot;D&quot;) { }
      } else {
          // natural order
          Button(&quot;B&quot;) { }
          Button(&quot;D&quot;) { }
          Button(&quot;A&quot;) { }
          Button(&quot;C&quot;) { }
      }
  }
  </code></pre>
  <p>This is for MacOS, thanks!</p>