Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only expand the label when the "more" bit is clicked #11

Open
ValCanBuild opened this issue Mar 13, 2019 · 8 comments
Open

Only expand the label when the "more" bit is clicked #11

ValCanBuild opened this issue Mar 13, 2019 · 8 comments

Comments

@ValCanBuild
Copy link

When using the expand text feature of the label in a tableview and it's a large portion of its height, it consumes clicks.

Describe the solution you'd like
Ideally only expand the label when the "more" bit is clicked.

@chansen22
Copy link
Contributor

chansen22 commented Mar 13, 2019

@ValCanBuild thanks for the issue! Would you mind making me a quick project that shows this off? It'll help me understand it a lot easier.

@pilky
Copy link
Contributor

pilky commented Mar 13, 2019

@chansen22 The issue is that the labelTappedBlock is called if you click anywhere on the label that isn't a link. Ideally we want it to be able to limit that to just when you click on the attributedTruncationToken, with all other taps (that aren't on links) passing through to the views behind (in our case a table cell)

@chansen22
Copy link
Contributor

👍 I get it. I think if you needed to get around this until I have some time to work up a way to handle this, you can subclass NantesLabel and override the touch handling. Although you might end up writing something similar to what I'd be writing for the feature itself.

As for adding this functionality, maybe something like a new var you can set to force it to only respond to touches inside the attributedTruncationToken, and then if that's set inside the tap handling, call into a new function that looks for the truncation token at the point you're touching at? If true, call the block, otherwise, continue on? Sounds kind of expensive, but I'll play around with it.

@ValCanBuild
Copy link
Author

Thanks, @chansen22, that's sounds exactly like what we want. I can understand it might be a bit expensive (though not too much) so you could have it as an optional setting on the label? var onlyExpandWhenTruncationClicked or whatever

@pilky
Copy link
Contributor

pilky commented Mar 13, 2019

@chansen22 yeah, though the only way I could think to do that was calculate the bounds within the text. I was playing around with a hack that worked out the bounds of the truncation token within the last line, which could be use for scoping the clicks.

Unfortunately I wasn't able to get the bounds origin in terms of the overall label bounds, so could only get it to work by assuming the last line would always be the bottom of the label. Also, due to my inexperience with CoreText I was only able to calculate the bounds by piggybacking on the drawTruncation code (which works, but feels somewhat "icky" to store frames calculated during the draw pass)

@haihoang88
Copy link

Hi,
Does anyone have an update on it? Or any work around available?

@Linkadi98
Copy link

any updates here?

@ZClee128
Copy link

Is there an update planned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants