How do you press the menu button when you press the menu button?

I am looking for some code so that the menu appears next to the button when pressed. What code do I need for this?

Sorry if this sounds a bit vague.

+1
source share
3 answers

Why not use NSPopUpButton?

+4
source

NSPopupButton was also my first thought. This is how apps with Action gear buttons execute their menus.

- , NSMenu +popUpContextMenu:withEvent:forView:. , NSMenu NSMenuItems NSApplication currentEvent getter.

+2

, , , NSPopupButtonCell NSMenu:

NSPopUpButtonCell *popupCell = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:YES];
[popupCell setMenu:yourMenu];
[popupCell trackMouse:event inRect:[yourButton bounds] ofView:yourButton untilMouseUp:YES];
[popupCell release];

pullsDown:, inRect:, andView: , , .

0

Source: https://habr.com/ru/post/1718931/


All Articles