Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

Remove menu actions from inputToolbar.contentView.textView #1321

Closed
lobyncev opened this issue Nov 23, 2015 · 9 comments
Closed

Remove menu actions from inputToolbar.contentView.textView #1321

lobyncev opened this issue Nov 23, 2015 · 9 comments

Comments

@lobyncev
Copy link

I want add custom menu action to JSQMessagesCollectionViewCell:
[JSQMessagesCollectionViewCell registerMenuAction:@selector(customAction:)]; (see in your demo code), then custom menu actions showing in content menu inputToolbar.contentView.textView.
How not showing custom action in inputToolbar.contentView.textView?
img_0512

@wdcurry
Copy link

wdcurry commented Dec 1, 2015

This would be awesome, but if memory serves, this is tied to how Apple has setup the hierarchy of things.

@jessesquires
Copy link
Owner

Hey @lobyncev 😄

I'm cleaning up old issues and trying to finish the next release of the library. I'm sorry I don't have time to respond to all questions.

I'm going to close this issue, but the community should feel free to continue the discussion.

Other ways to get help:

@jessesquires
Copy link
Owner

I believe @wdcurry is correct. Unfortunately, I can't confirm right now.

@dterekhov
Copy link

Hi guys! I found a way to add additional menu items to bubbles exclude inputToolbar.contentView.textView without touch any code of original JSQMessagesViewController.

In my subclass (for example DemoMessagesViewController) I added a private category at the top class:

/**
 *  Category for using private members to handle appearing menu by long tap
 */
@interface JSQMessagesViewController (Private)

@property (nonatomic, readonly) NSIndexPath *selectedIndexPathForMenu;
- (void)jsq_didReceiveMenuWillShowNotification:(NSNotification *)notification;

@end


@implementation DemoMessagesViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Register additional long tap menu actions
    [JSQMessagesCollectionViewCell registerMenuAction:@selector(customAction:)];
}

#pragma mark - Private
- (void)jsq_didReceiveMenuWillShowNotification:(NSNotification *)notification {
    // Setup menuItems for bubble cell
    if (super.selectedIndexPathForMenu) {
        [UIMenuController sharedMenuController].menuItems = @[ [[UIMenuItem alloc] initWithTitle:@"Custom Action"
                                                                                          action:@selector(customAction:)] ];
    }

    [super jsq_didReceiveMenuWillShowNotification:notification];

    // Setup menuItems for input TextView
    [UIMenuController sharedMenuController].menuItems = nil;
}

@end

I tried any variants. But this one works for me.

@jessesquires
Copy link
Owner

Thanks for the update @dterekhov !

Maybe the library can provide a method that clients can override?

- (void)didReceiveMenuWillShowNotification:(NSNotification *)notification forIndexPath:(NSIndexPath *)indexPath;

The private method can call this, and clients can override to do what you've done here.

Would this work for you? Would you like to submit a PR for this?

@jessesquires jessesquires added this to the 7.2.1 milestone Feb 15, 2016
@jessesquires jessesquires reopened this Feb 15, 2016
@wdcurry
Copy link

wdcurry commented Feb 15, 2016

This would be very welcome..

@eliburke
Copy link
Collaborator

eliburke commented May 1, 2016

@jessesquires Take a look at #1563.
Thoughts:

  • existing behavior is preserved.. if you are adding a custom menu item in your JSQMessagesViewController subclass, it will show up for all cells and the inputView.
  • I don't know if the collectionView's datasource was the right place to put this
  • as an alternative, registerAction could take an additional parameter for the menu item's name and we could handle this automatically

@jessesquires
Copy link
Owner

Based on #1563 (a breaking change) going to bump this to v8.0 😄

@jessesquires jessesquires modified the milestones: 8.0.0, 7.2.1 May 2, 2016
@eliburke
Copy link
Collaborator

eliburke commented May 2, 2016

Ok, but FWIW, it doesn't break anything. The protocol is optional and the behavior of one's menus is unchanged if you don't implement the new function.

@jessesquires jessesquires modified the milestones: 7.2.1, 8.0.0 May 23, 2016
pcoltau added a commit to TeletronicsDotAe/JSQMessagesViewController that referenced this issue Apr 16, 2017
…iewController

* 'master' of https://github.com/jessesquires/JSQMessagesViewController: (86 commits)
  ImageOptim on assets (jessesquires#1845)
  update changelog and spec for 7.3.4
  Fix issue jessesquires#1583: Don't highlight cell outside message bubble (when long press) (jessesquires#1744)
  update changelog and version for 7.3.3
  Updated `canPerformAction:withSender:` in `JSQMessagesComposerTextView` to call super (jessesquires#1664). Fixes jessesquires#1663.
  Update CHANGELOG and version nums for 7.3.2
  fix KVO crash. close jessesquires#1631
  formatting
  small fix regarding scrollToIndexPath (jessesquires#1642) close jessesquires#1640
  Update CHANGELOG.md
  update CHANGLOG. bump version numbers
  Reverted jessesquires#1588 to fix jessesquires#1602 and fix jessesquires#1604. (jessesquires#1623)
  bump version numbers
  Update CHANGELOG.md
  provide default init values for JSQMessagesCollectionViewLayoutAttributes to prevent assertion. fix jessesquires#1338
  follow up for jessesquires#1247 and jessesquires#1591. obfuscate private APIs. swizzle via +initialize
  copy attributes
  clean up
  fix keyboard hiding bug on iOS 9 (jessesquires#1307). fix jessesquires#1063
  - cleanup from PR jessesquires#1281 - fix menu actions, close jessesquires#1321 - make notification methods public - partially apply changes from PR jessesquires#1563
  ...
pcoltau added a commit to TeletronicsDotAe/JSQMessagesViewController that referenced this issue Apr 16, 2017
…nch3

* origin/master: (66 commits)
  ImageOptim on assets (jessesquires#1845)
  update changelog and spec for 7.3.4
  Fix issue jessesquires#1583: Don't highlight cell outside message bubble (when long press) (jessesquires#1744)
  update changelog and version for 7.3.3
  Updated `canPerformAction:withSender:` in `JSQMessagesComposerTextView` to call super (jessesquires#1664). Fixes jessesquires#1663.
  Update CHANGELOG and version nums for 7.3.2
  fix KVO crash. close jessesquires#1631
  formatting
  small fix regarding scrollToIndexPath (jessesquires#1642) close jessesquires#1640
  Update CHANGELOG.md
  update CHANGLOG. bump version numbers
  Reverted jessesquires#1588 to fix jessesquires#1602 and fix jessesquires#1604. (jessesquires#1623)
  bump version numbers
  Update CHANGELOG.md
  provide default init values for JSQMessagesCollectionViewLayoutAttributes to prevent assertion. fix jessesquires#1338
  follow up for jessesquires#1247 and jessesquires#1591. obfuscate private APIs. swizzle via +initialize
  copy attributes
  clean up
  fix keyboard hiding bug on iOS 9 (jessesquires#1307). fix jessesquires#1063
  - cleanup from PR jessesquires#1281 - fix menu actions, close jessesquires#1321 - make notification methods public - partially apply changes from PR jessesquires#1563
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants