optonaut/ActiveLabel.swift

How do I detect the tap of the rest of the text

buluoray opened this issue · 4 comments

I would like to know how to detect text other than the one I set. For example, I set I only want Hashtag, and I will also get a callback when I tap text other than hashtag

I figured it out.

How did you solve it?
@buluoray

@krgoodnews you can use custom type with regex pattern, had success with this:

let customType = ActiveType.custom(pattern: "(?:^|(?<= ))([^#|^@]+)")
label.enabledTypes = [.hashtag, .mention, customType]

@krgoodnews I modified the package. Basically, add an else statement in onTouch case .ended

case .ended, .regionExited: guard let selectedElement = selectedElement else { didTapNormalText() return avoidSuperCall }

fileprivate func didTapNormalText() { guard let textTapHandler = textTapHandler else { delegate?.didSelect("Tap normal text", type: .custom(pattern: "")) return } textTapHandler() }

internal var textTapHandler: (() -> ())?