Skip to content

Instantly share code, notes, and snippets.

@steventroughtonsmith
Last active July 27, 2022 15:48
Show Gist options
  • Save steventroughtonsmith/eea3a62e58e1a34ee580276a180c54f5 to your computer and use it in GitHub Desktop.
Save steventroughtonsmith/eea3a62e58e1a34ee580276a180c54f5 to your computer and use it in GitHub Desktop.
UIKit right-click interaction
//
// RCGRightClickGestureRecognizer.swift
// RightClickGestureRecognizer
//
// Created by Steven Troughton-Smith on 27/07/2022.
//
import UIKit
class RCGRightClickInteraction: UIContextMenuInteraction {
class RCGRightClickGestureRecognizerDelegate: NSObject, UIContextMenuInteractionDelegate {
var parent:RCGRightClickInteraction? = nil
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
parent?.handler(location)
return nil
}
}
var handler:(_:CGPoint) -> Void = { _ in }
let _delegate = RCGRightClickGestureRecognizerDelegate()
init(handler:@escaping (_:CGPoint) -> Void ) {
super.init(delegate: _delegate)
_delegate.parent = self
self.handler = handler
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment