From 7387efe3ddd3ad7440d54ba1ab10e5806da63ba7 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 3 Dec 2010 14:09:15 +0000 Subject: =?UTF-8?q?=E2=80=A2=20further=20work=20on=20the=20choosMenuItem?= =?UTF-8?q?=20[not=20yet=20working]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPChooseMenuItemDialog.m | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'Source/SPChooseMenuItemDialog.m') diff --git a/Source/SPChooseMenuItemDialog.m b/Source/SPChooseMenuItemDialog.m index 2dc73077..e966613b 100644 --- a/Source/SPChooseMenuItemDialog.m +++ b/Source/SPChooseMenuItemDialog.m @@ -27,4 +27,68 @@ @implementation SPChooseMenuItemDialog +@synthesize contextMenu; + +- (id)init; +{ + if(self = [self initWithContentRect:NSMakeRect(10,10,10,10) + styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) + { + ; + } + return self; +} + +- (void)dealloc +{ + [tv release]; + [super dealloc]; +} + +- (void)initMeWithOptions:(NSDictionary *)displayOptions +{ + [self setReleasedWhenClosed:YES]; + [self setLevel:NSNormalWindowLevel]; + [self setHidesOnDeactivate:YES]; + [self setHasShadow:YES]; + [self setAlphaValue:0.9]; + tv = [[NSTextView alloc] initWithFrame:NSMakeRect(10,10,10,10)]; + [self setContentView:tv]; + [tv setDelegate:self]; + [tv setEditable:YES]; +} + ++ (void)displayMenu:(NSMenu*)theMenu atPosition:(NSPoint)location +{ + + SPChooseMenuItemDialog *dialog = [SPChooseMenuItemDialog new]; + [dialog initMeWithOptions:nil]; + + NSMenuItem *returnItem = nil; + + [dialog setContextMenu:theMenu]; + [dialog setFrameTopLeftPoint:location]; + + [dialog orderFront:nil]; + NSEvent *theEvent = [NSEvent + mouseEventWithType:NSRightMouseDown + location:NSMakePoint(1,1) + modifierFlags:0 + timestamp:1 + windowNumber:[dialog windowNumber] + context:[NSGraphicsContext currentContext] + eventNumber:1 + clickCount:1 + pressure:0.0]; + + [[NSApplication sharedApplication] postEvent:theEvent atStart:NO]; + +} + +- (NSMenu *)menuForEvent:(NSEvent *)event +{ + NSLog(@"asdasdasd"); + return contextMenu; +} + @end -- cgit v1.2.3