fix: remove duplicate canPerformAction method and merge with existing implementation
- Keep single canPerformAction method that handles both text selection menu and highlight menu - Check tappedHighlight first, then fall back to text selection logic - Resolves method override conflict Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d56e99a83f
commit
7c16647306
@ -1004,6 +1004,12 @@ private final class PDFDemoPageView: UIView, RDPDFReaderPageInteractable, UIGest
|
||||
override var canBecomeFirstResponder: Bool { true }
|
||||
|
||||
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
|
||||
if tappedHighlight != nil {
|
||||
return action == #selector(rd_copy_highlight(_:))
|
||||
|| action == #selector(rd_delete_highlight(_:))
|
||||
|| action == #selector(rd_annotate_highlight(_:))
|
||||
|| action == #selector(rd_delete_annotation(_:))
|
||||
}
|
||||
guard let selection = textLayer.selectedSelection else { return false }
|
||||
switch action {
|
||||
case #selector(rd_copy(_:)):
|
||||
@ -1114,16 +1120,6 @@ private final class PDFDemoPageView: UIView, RDPDFReaderPageInteractable, UIGest
|
||||
menuController.setMenuVisible(true, animated: true)
|
||||
}
|
||||
|
||||
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
|
||||
if tappedHighlight != nil {
|
||||
return action == #selector(rd_copy_highlight(_:))
|
||||
|| action == #selector(rd_delete_highlight(_:))
|
||||
|| action == #selector(rd_annotate_highlight(_:))
|
||||
|| action == #selector(rd_delete_annotation(_:))
|
||||
}
|
||||
return super.canPerformAction(action, withSender: sender)
|
||||
}
|
||||
|
||||
@objc private func rd_copy_highlight(_ sender: Any?) {
|
||||
guard let highlight = tappedHighlight,
|
||||
let text = highlight.selectedText?.trimmingCharacters(in: .whitespacesAndNewlines),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user