Delay contextMenu on SwiftUI

I'm trying to delay when the contextMenu appears because I have a drag gesture over the same view which causes a confuse user experience.

My code:

…
Text(exampleText)
  .contextMenu
  {
    delay()

    // Menus here
  }
  .gesture(
    DragGesture()
      .onEnded(
        { end in
          switch exampleTextAlignment
          {
            case .leading:
              if end.translation.width > 0
              {
                exampleTextAlignment = .center
                onContextMenuAlignment = .top
              }
            case .center:
            if end.translation.width < 0
              {
                exampleTextAlignment = .leading
                onContextMenuAlignment = .topLeading
              }
            else if end.translation.width > 0
              {
                exampleTextAlignment = .trailing
                onContextMenuAlignment = .topTrailing
              }
            case .trailing:
              if end.translation.width < 0
              {
                exampleTextAlignment = .center
                onContextMenuAlignment = .top
              }
          }
        }
      )
    )
…

where delay() is:

…
private func delay() async {
        try? await Task.sleep(nanoseconds: UInt64(secondsHere * Double(NSEC_PER_SEC)))
        hasTimeElapsed = true
    }
…

Xcode v.13.2 and iOS v.15.2.

Here's a more detailed question: https://stackoverflow.com/questions/71201562/delay-contextmenu-on-swiftui

Delay contextMenu on SwiftUI
 
 
Q