Re: Contextual Menu
Re: Contextual Menu
- Subject: Re: Contextual Menu
- From: Keith Alperin <email@hidden>
- Date: Tue, 12 Apr 2005 00:04:23 -0500
Well, i've made some progress. I was able to determine that the 6th argument is not the context, but rather the timeStamp. I used the carbon "GetCurrentEventTime()" function in order to get an NSTimeInterval and now it looks like this and compiles cleanly:
NSEvent *event = [NSEvent mouseEventWithType:NSRightMouseDown
location:point
modifierFlags:NSCommandKeyMask | NSDownArrowFunctionKey
timestamp:GetCurrentEventTime()
windowNumber:1
context:context
eventNumber:1
clickCount:1
pressure:0.0];
Unfortunately, the menu that I get with
NSMenu *menu = [textField menuForEvent:event];
is nil, so I'm not there yet.
Any thoughts on whether this is the correct way to get a contextual menu to show would be greatly appreciated.
Best,
Keith
On Apr 11, 2005, at 7:33 AM, Keith Alperin wrote:
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
_______________________________________________
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