Contextual Menu
Contextual Menu
- Subject: Contextual Menu
- From: Keith Alperin <email@hidden>
- Date: Mon, 11 Apr 2005 07:33:33 -0500
Greetings cocoa-devs! I'm a cocoa newbie and I'm working on a prototype whereby I can make the contextual menu for an NSTextField appear when I click a button. Ultimately, I would like to be able to make the contextual menu appear when i hit a certain key combination. I'm trying to use
popUpContextMenu:withEvent:forView: on NSMenu, which necessitates having both an NSEvent and an NSMenu. Currently I'm stuck on creating the event. The following code yields a
<x-tad-smaller>"error: incompatible type for argument 6 of indirect function call" </x-tad-smaller>at compile time:
<x-tad-smaller>
</x-tad-smaller>
NSEvent *event = [NSEvent mouseEventWithType:NSRightMouseDown
location:point
modifierFlags:NSCommandKeyMask | NSDownArrowFunctionKey
timestamp:[NSEvent timeStamp]
windowNumber:0
context:[NSGraphicsContext currentContext]
eventNumber:1
clickCount:1
pressure:0.0];
Once I have the event, I'll call
menuForEvent: on my NSTextField to get the menu and then I can call
popUpContextMenu:withEvent:forView
My questions are:
1) Is this the correct way to get the contextual menu to show or should I try something else (such as just posting the right mouse click event)?
2) What is causing my compilation error. It looks to me like the 6th argument (context) is indeed an NSGraphicsContext?
Thank you all so much,
Keith R. Alperin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden