Adding copy/paste support from MessagesViewController#248
Conversation
| registerReusableViews() | ||
| setupDelegates() | ||
|
|
||
| self.addMenuControllerObservers() |
| addGestureRecognizer(tapGesture) | ||
| tapGesture.delegate = self | ||
|
|
||
| let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(handleGesture(_:))) |
|
|
||
| extension MessagesViewController: UICollectionViewDelegate { | ||
|
|
||
| public func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool { |
| return false | ||
| } | ||
|
|
||
| public func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool { |
| return (action == NSSelectorFromString("copy:")) | ||
| } | ||
|
|
||
| public func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) { |
| } | ||
|
|
||
| fileprivate var targetedCell:UICollectionViewCell? | ||
| fileprivate var targetedFrame = CGRect.zero |
There was a problem hiding this comment.
Can we keep properties at the top of the file like we're doing with the rest of them?
Can we also put all of the logic related to the MenuController in an extension under Keyboard Handling?
|
@SD10 Thanks for feedbacks. I did all suggested fixes. I have nothing to say about what u suggested, except for putting all properties at the top. I usually like to put them close to methods that are using it so refactoring is easier, scope is more concise. However, then we cannot use extensions which is also a good way to break the code. So both solution is fine with me. The best would be to be able to add properties in an extension :) |
|
@Ganzolo Can you add a CHANGELOG entry for this? |
|
Me too, I just have to make sure the gestures are behaving properly. If either of you can pull it and run it that would be great. I will try myself again soon. I think there was some inconsistency with the gestures last time I tested it. Sometimes the copy menu would be displayed for a long press. Sometimes for a long press and lift up. Things like that. |
nathantannar4
left a comment
There was a problem hiding this comment.
Looks like a good feature we need
|
@nathantannar4 Were you able to test the gestures?Yes we definitely need it but it needs to be working properly. Sent with GitHawk |
|
@SD10 @Ganzolo I notice that the "Copy" prompt appears even when a long press is recognized on the AvatarView or anywhere else outside of the MessageLabel. Is this behavior we want? Only other thing I see is if you long press a link such as an address, the "Copy" prompt appears before the notifier is sent that the user has tapped an address. I wonder if this can be prevented? |
|
@nathantannar4 Thanks for the extra set of eyes. I definitely missed some of those. These are all valid points. Looks like we're going to have to look into this a little bit more. It's a pretty important feature to have but easy enough for clients to implement on their own while we figure this out. |
|
@SD10 @nathantannar4 I tried to make contentView transparent background or to assign a long press gesture to background of cell. But it does not work. The other idea would be to respond false when this method is called only when the touch is not in the bubble area. However I didn't find a way to get the position of the touch from this method.
|
|
Sorry, just now getting to this. For your consideration - add a long press gesture recognizer to |
|
Hello! I can't call the menu with long press (copy, custom action...). when will this function be in MessageKit? Or help me, please, to write the right code. It was not the problem to call this menu on JSQ. |
|
Hey @relaxsus, You can remove the long press gesture from your MessageKit copy for now. Right now we require people to add copy/paste support themselves. I agree this feature is something we should provide, but due to its ease of implementation outside of MessageKit, I’ve spent my time trying to resolve more serious issues. It’s on the roadmap though Sent with GitHawk |
(Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.)
What does this implement/fix? Explain your changes.
Copy implementation
Does this close any currently open issues?
#143
Any other comments?
Better implementation