mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 08:42:51 +00:00
Delete no-longer-used InteractiveLabel.
This commit is contained in:
1 parent
010a23933c
commit
6778fc79eb
1 file changed
-71
@@ -1,71 +0,0 @@
|
||||
//
|
||||
// InteractiveLabel.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Maurice Parker on 11/3/19.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
#if os(iOS)
|
||||
|
||||
import UIKit
|
||||
|
||||
@IBDesignable
|
||||
public final class InteractiveLabel: UILabel, @preconcurrency UIEditMenuInteractionDelegate {
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
commonInit()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
commonInit()
|
||||
}
|
||||
|
||||
func commonInit() {
|
||||
let gestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressGesture(_:)))
|
||||
self.addGestureRecognizer(gestureRecognizer)
|
||||
|
||||
let editMenuInteraction = UIEditMenuInteraction(delegate: self)
|
||||
addInteraction(editMenuInteraction)
|
||||
|
||||
self.isUserInteractionEnabled = true
|
||||
}
|
||||
|
||||
@objc func handleLongPressGesture(_ recognizer: UIGestureRecognizer) {
|
||||
guard recognizer.state == .began, let recognizerView = recognizer.view else {
|
||||
return
|
||||
}
|
||||
|
||||
if let interaction = recognizerView.interactions.first(where: { $0 is UIEditMenuInteraction }) as? UIEditMenuInteraction {
|
||||
let location = recognizer.location(in: recognizerView)
|
||||
let editMenuConfiguration = UIEditMenuConfiguration(identifier: nil, sourcePoint: location)
|
||||
interaction.presentEditMenu(with: editMenuConfiguration)
|
||||
}
|
||||
}
|
||||
|
||||
public override var canBecomeFirstResponder: Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
public override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
|
||||
return (action == #selector(UIResponderStandardEditActions.copy(_:)))
|
||||
}
|
||||
|
||||
public override func copy(_ sender: Any?) {
|
||||
UIPasteboard.general.string = text
|
||||
}
|
||||
|
||||
// MARK: - UIEditMenuInteractionDelegate
|
||||
|
||||
public func editMenuInteraction(_ interaction: UIEditMenuInteraction, menuFor configuration: UIEditMenuConfiguration, suggestedActions: [UIMenuElement]) -> UIMenu? {
|
||||
|
||||
let copyAction = UIAction(title: "Copy", image: nil) { [weak self] _ in
|
||||
self?.copy(nil)
|
||||
}
|
||||
return UIMenu(title: "", children: [copyAction])
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user