Messagekit: Add copy menu for long press gesture on message bubbles

Created on 21 Sep 2017  路  9Comments  路  Source: MessageKit/MessageKit

Since we're not using UITextView for the message label, the text is not selectable.
We should add support for copying the text of the MessageLabels.

enhancement

Most helpful comment

In JSQMVC, uitextview was being used. The main problem was that, when you use the UIMenuController, there was a conflict between the collection view's UIMenuController and textview's. When you want to allow data detectors, you need to set uitextview selectable. Once you set it as selectable, then it would allow data detectors, then there will be a conflict with the collection view's UIMenuController. Therefore, we couldn't have used data detectors in JSQMVC.

I think we can use the collection view's UIMenuController to copy the texts. These way we can easily copy both texts and media messages.

All 9 comments

I'm interested in this one.
Should I take it from the 0.8.0 branch?
Is there any particular reason we are not using UITextView?
What kind of UI do you have in mind? It would be cool maybe something fancy like Telegram and WhatsApp, but 铮縈essages shows a simple action sheet as the copy control 馃槀

Hey @etoledom, I'm working on trying to finish up v0.8.0 now so this is probably better for v0.9.0+
I know @Ganzolo expressed interest in this and may have started working on it.

We're not using UITextView because I was advised not to -- which is good enough for me :)

As for the UI, I'm thinking something like the old iMessage/JSQMVC style. Although, the greater flexibility we can provide the better 馃槂

Cool! Let鈥檚 hope @Ganzolo can tell us if he is in this 馃槄.

145 is interesting for me too, I have been working a lot with maps lately.

In JSQMVC, uitextview was being used. The main problem was that, when you use the UIMenuController, there was a conflict between the collection view's UIMenuController and textview's. When you want to allow data detectors, you need to set uitextview selectable. Once you set it as selectable, then it would allow data detectors, then there will be a conflict with the collection view's UIMenuController. Therefore, we couldn't have used data detectors in JSQMVC.

I think we can use the collection view's UIMenuController to copy the texts. These way we can easily copy both texts and media messages.

Awesome @hamzaozturk thanks for this clear explanation and the valuable insight 鉂わ笍

Yes, I started working on it, I am going to PR something very soon, within next couple of days.

Just sharing some progress here. I am using following set of requirements for implementing copy :

  • Copy Menu should be centered above message container (a.k.a bubbles)
  • Message container should be the only clickable zone to display menu. Meaning clicking on white background of a message cell should not trigger this menu
  • Color of message should be slightly highlighted to reflect selection
  • Whole MessageCollectionView's scrollview should stop allowing scrolling when having menu displayed. In my tests, this prevents Copy message to be misaligned when scrolling (and also this is default behavior of most other tasks, Messages and Viber for instance).

So far the only lines I had to deactivate to start working on this feature is Long press gesture on MessageLabel.swift @SD10 would tell if it's acceptable.

@Ganzolo Yes the long press gesture for MessageLabel should be used for this. Those sound like good requirements to me.

This is resolved by #422 in MessageKit 13.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mlequeux picture mlequeux  路  3Comments

Abacaxi-Nelson picture Abacaxi-Nelson  路  4Comments

emmanuelay picture emmanuelay  路  3Comments

asn111 picture asn111  路  3Comments

ChandraPrakashJangid picture ChandraPrakashJangid  路  3Comments