diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 7acb4691..01ffb3db 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -254,7 +254,6 @@ public typealias ActionBlock = () -> Void label.addGestureRecognizer(tapGesture) } } - default: continue } @@ -363,8 +362,8 @@ extension Label { @objc func textLinkTapped(_ gesture: UITapGestureRecognizer) { for clause in clauses { - if gesture.didTapAttributedTextInLabel(self, inRange: clause.range), let action = clause.actionBlock { - action() + if gesture.didTapAttributedTextInLabel(self, inRange: clause.range) { + clause.performAction() } } } @@ -435,7 +434,6 @@ extension Label { } } - extension UITapGestureRecognizer { func didTapAttributedTextInLabel(_ label: Label, inRange targetRange: NSRange) -> Bool { @@ -453,13 +451,6 @@ extension UITapGestureRecognizer { let labelSize = label.bounds.size textContainer.size = labelSize - // Find the tapped character location and compare it to the specified range -// let locationOfTouchInLabel = location(in: label) -// let textBoundingBox = layoutManager.usedRect(for: textContainer) -// let textContainerOffset = CGPoint(x: (labelSize.width - textBoundingBox.size.width) * 0.5 - textBoundingBox.origin.x, -// y: (labelSize.height - textBoundingBox.size.height) * 0.5 - textBoundingBox.origin.y) -// let locationOfTouchInTextContainer = CGPoint(x: locationOfTouchInLabel.x - textContainerOffset.x, -// y: locationOfTouchInLabel.y - textContainerOffset.y) let indexOfCharacter = layoutManager.characterIndex(for: location(in: label), in: textContainer, fractionOfDistanceBetweenInsertionPoints: nil) return NSLocationInRange(indexOfCharacter, targetRange) diff --git a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift index 375945a1..3daeb3b9 100644 --- a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift +++ b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift @@ -213,8 +213,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt actionBlock = { [weak self, weak delegateObject] in var performAction = true - if let wSelf = self, - let wButtonDelegate = (delegateObject as? MVMCoreUIDelegateObject)?.buttonDelegate, + if let wSelf = self, let wButtonDelegate = (delegateObject as? MVMCoreUIDelegateObject)?.buttonDelegate, wButtonDelegate.responds(to: #selector(ButtonObjectDelegate.button(_:shouldPerformActionWithMap:additionalData:))) { performAction = wButtonDelegate.button?(wSelf, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? false }