Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a context menu to an app

Whatsapp screenshot

I would like to know how to implement this "context menu" with action buttons like the one that appears on whatsapp and other apps when you click message.

Thank you very much.

like image 218
Eironeia Avatar asked Jul 06 '17 05:07

Eironeia


People also ask

How do I enable context menu?

If you want to enable the taskbar context menu, select the Not configured or Disabled option in the pop-up window. To disable the taskbar context menu, select the Enabled option. Click Apply, click OK, and then restart your device to save these changes.

How do I get my context menu back?

Right-click the newly created key, select the New menu and select the Key option. Name the key InprocServer32 and press Enter. Double-click the newly created key and set its value to blank to enable the classic context menu on Windows 11. Click the OK button.

Where do I find context menu?

In Microsoft Windows, pressing the Application key or Shift+F10 opens a context menu for the region that has focus.


1 Answers

That is UIMenuController. I am not good with swift. For Swift please check this link. Objective C code is as follows:

- (void)showMenu
{
    UIMenuController *menu = [UIMenuController sharedMenuController];
    menu.menuItems = @[
       [[UIMenuItem alloc] initWithTitle:@"Title1" action:@selector(MyAction1)],
       [[UIMenuItem alloc] initWithTitle:@"Title2" action:@selector(MyAction2)],
       [[UIMenuItem alloc] initWithTitle:@"Title3" action:@selector(MyAction)]];
    [menu setTargetRect:self.bounds inView:self];
    [menu setMenuVisible:YES animated:YES];
}
like image 143
Amal T S Avatar answered Sep 19 '22 15:09

Amal T S