Closed cruisediary closed 5 years ago
This is a known problem, but haven't find a solution for it
How about adding pattern like '\s' to solve this problem
that pattern cause event but do nothing, not changing selected color
and hash, mention, url patterns should not affected same to complementary set
if someone use custom pattern comprising '\t,\n~' doesn't help this
but this patterns can't solve last sentense cause this problem, must be adjusted if last sentence of activeLabel fully filled the labels's empty rect then doesn't need to add space char but if can add space and doesn't change label's height, add space to match above pattern
Is this way can solve this problem and moreover attributedText problem?
Hi @cruisediary I don't quite get your workaround.
If you think that you have a good solution, I would be really have to receive a PR
The issue is due to setting the index with layoutManager.glyphIndex
in the ActiveLabel.swift element(at location: CGPoint)
method.
As per the docs:
If no glyph is under point, the nearest glyph is returned.
Therefore when you tap in the whitespace, it actually grabs the nearest glyph and uses that location. Hence why you need to replace your current if index is in element
check in element(at location: CGPoint)
with the following:
let elementRect = layoutManager.boundingRect(forGlyphRange: element.range, in: textContainer)
if elementRect.contains(correctLocation){
return element
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I love this framework
but unfortunately i found somthing like bug
this is simple project
environment
just set hashtag normal and selected color , mentiontag normal and selected color
and set text to
"#1234\n#1234\n#5678\n@asdf\n\n\n#asdfa\n#asdfasdf\n\n"
problem is before tag selected when i touch empty rect
is this duplicated problem, how can i fix it :)