FROM : Keith Alperin
DATE : Mon Apr 11 14:33:33 2005
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 "error:
incompatible type for argument 6 of indirect function call" at compile
time:
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
DATE : Mon Apr 11 14:33:33 2005
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 "error:
incompatible type for argument 6 of indirect function call" at compile
time:
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
| Related mails | Author | Date |
|---|---|---|
| Keith Alperin | Apr 11, 14:33 | |
| Keith Alperin | Apr 12, 07:04 | |
| Keith Alperin | Apr 28, 14:35 |






Cocoa mail archive

