Skip to content

Adding copy/paste support from MessagesViewController#248

Closed
Ganzolo wants to merge 2 commits into
developmentfrom
feature/copySupportForMessageTextAndImage
Closed

Adding copy/paste support from MessagesViewController#248
Ganzolo wants to merge 2 commits into
developmentfrom
feature/copySupportForMessageTextAndImage

Conversation

@Ganzolo

@Ganzolo Ganzolo commented Oct 9, 2017

Copy link
Copy Markdown

(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

registerReusableViews()
setupDelegates()

self.addMenuControllerObservers()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove self here?

addGestureRecognizer(tapGesture)
tapGesture.delegate = self

let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(handleGesture(_:)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have to look into this


extension MessagesViewController: UICollectionViewDelegate {

public func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be marked as open

return false
}

public func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be marked as open

return (action == NSSelectorFromString("copy:"))
}

public func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be marked as open

}

fileprivate var targetedCell:UICollectionViewCell?
fileprivate var targetedFrame = CGRect.zero

@SD10 SD10 Oct 9, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SD10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Ganzolo 👍 I just have to review the Long Press Gesture and any other gesture conflicts. I left you some comments regarding how I think we should organize the code

@Ganzolo

Ganzolo commented Oct 10, 2017

Copy link
Copy Markdown
Author

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

@SD10

SD10 commented Oct 17, 2017

Copy link
Copy Markdown
Member

@Ganzolo Can you add a CHANGELOG entry for this?

@SD10 SD10 assigned cwalo and nathantannar4 and unassigned cwalo and nathantannar4 Oct 20, 2017
@SD10 SD10 requested review from cwalo and nathantannar4 October 20, 2017 21:17
@SD10

SD10 commented Oct 20, 2017

Copy link
Copy Markdown
Member

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 nathantannar4 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good feature we need

@SD10

SD10 commented Oct 20, 2017

Copy link
Copy Markdown
Member

@nathantannar4 Were you able to test the gestures?Yes we definitely need it but it needs to be working properly.

Sent with GitHawk

@nathantannar4

Copy link
Copy Markdown
Member

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

@SD10

SD10 commented Oct 21, 2017

Copy link
Copy Markdown
Member

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

@Ganzolo

Ganzolo commented Oct 23, 2017

Copy link
Copy Markdown
Author

@SD10 @nathantannar4
I looked today into this issue and I am afraid that we would need to use custom touch on a Cell level to prevent this behavior from happening.

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.

func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool

@cwalo

cwalo commented Oct 26, 2017

Copy link
Copy Markdown
Contributor

Sorry, just now getting to this. For your consideration - add a long press gesture recognizer to MessageLabel and either pass the gesture type (maybe via a custom enum) along in the MessageLabelDelegate methods and/or have an additional didLongPressMessageLabel delegate method with a default implementation that displays the MenuController. @Ganzolo @SD10 @nathantannar4

@SD10

SD10 commented Oct 26, 2017

Copy link
Copy Markdown
Member

@cwalo Good suggestions. We may have to move this to the cell level as @Ganzolo mentioned. I'm going to be rewriting MessageLabel and then we can re-evaluate from there

@SD10 SD10 changed the base branch from v0.10.0 to v0.11.0 October 30, 2017 01:58
@SD10 SD10 changed the base branch from v0.11.0 to development November 2, 2017 03:57
@relaxsus

Copy link
Copy Markdown

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.

@SD10

SD10 commented Nov 20, 2017

Copy link
Copy Markdown
Member

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

@nathantannar4

Copy link
Copy Markdown
Member

#422

@SD10 SD10 deleted the feature/copySupportForMessageTextAndImage branch February 23, 2018 12:03
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

Successfully merging this pull request may close these issues.

5 participants