문제

I want my status menu to call a function when it is clicked. What's the method that would let me assign that action? Something like this below but for the menu itself.

NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:@"Title" action:@selector(doX) keyEquivalent:@""];

도움이 되었습니까?

해결책

You can hook into the menu opening event by setting your menu's delegate and implementing the protocol method -[<NSMenuDelegate> menuWillOpen:] in the delegate you designate.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top