Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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