Nantes icon indicating copy to clipboard operation
Nantes copied to clipboard

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

Open ValCanBuild opened this issue 5 years ago • 8 comments

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.

ValCanBuild avatar Mar 13 '19 12:03 ValCanBuild

@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.

chansen22 avatar Mar 13 '19 16:03 chansen22

@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)

pilky avatar Mar 13 '19 16:03 pilky

👍 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.

chansen22 avatar Mar 13 '19 16:03 chansen22

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

ValCanBuild avatar Mar 13 '19 16:03 ValCanBuild

@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)

pilky avatar Mar 13 '19 16:03 pilky

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

haihoang88 avatar Nov 23 '19 12:11 haihoang88

any updates here?

Linkadi98 avatar Jul 28 '21 04:07 Linkadi98

Is there an update planned?

ZClee128 avatar Oct 17 '23 07:10 ZClee128