aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPChooseMenuItemDialog.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2013-01-25 21:24:57 +0000
committerstuconnolly <stuart02@gmail.com>2013-01-25 21:24:57 +0000
commit4faf9d57efd88123216f78b292886a5ee086e421 (patch)
treea590a60263af5ef317e51ed68620c4c449aba99b /Source/SPChooseMenuItemDialog.m
parent23833c899c531705557443da649c1f13701dc197 (diff)
downloadsequelpro-4faf9d57efd88123216f78b292886a5ee086e421.tar.gz
sequelpro-4faf9d57efd88123216f78b292886a5ee086e421.tar.bz2
sequelpro-4faf9d57efd88123216f78b292886a5ee086e421.zip
Fix more warnings.
Diffstat (limited to 'Source/SPChooseMenuItemDialog.m')
-rw-r--r--Source/SPChooseMenuItemDialog.m34
1 files changed, 22 insertions, 12 deletions
diff --git a/Source/SPChooseMenuItemDialog.m b/Source/SPChooseMenuItemDialog.m
index a4bb12bb..4bfdcbcb 100644
--- a/Source/SPChooseMenuItemDialog.m
+++ b/Source/SPChooseMenuItemDialog.m
@@ -47,13 +47,13 @@
- (IBAction)menuItemHandler:(id)sender
{
- [[self delegate] setSelectedItemIndex:[sender tag]];
- [[self delegate] setWaitForChoice:NO];
+ [(SPChooseMenuItemDialog *)[self delegate] setSelectedItemIndex:[sender tag]];
+ [(SPChooseMenuItemDialog *)[self delegate] setWaitForChoice:NO];
}
- (NSMenu *)menuForEvent:(NSEvent *)event
{
- return [[self delegate] contextMenu];
+ return [(SPChooseMenuItemDialog *)[self delegate] contextMenu];
}
@end
@@ -66,7 +66,7 @@
- (id)init;
{
- if ((self = [super initWithContentRect:NSMakeRect(1,1,2,2)
+ if ((self = [super initWithContentRect:NSMakeRect(1, 1, 2, 2)
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO]))
@@ -95,31 +95,41 @@
+ (NSInteger)withItems:(NSArray*)theList atPosition:(NSPoint)location
{
-
- if(!theList || ![theList count]) return -1;
+ if (!theList || ![theList count]) return -1;
SPChooseMenuItemDialog *dialog = [SPChooseMenuItemDialog new];
[dialog initDialog];
- NSMenu *theMenu = [[[NSMenu alloc] init] autorelease];
NSInteger cnt = 0;
- for(id item in theList) {
+ NSMenu *theMenu = [[[NSMenu alloc] init] autorelease];
+
+ for (id item in theList)
+ {
NSMenuItem *aMenuItem;
- if([item isKindOfClass:[NSString class]])
+
+ if ([item isKindOfClass:[NSString class]]) {
aMenuItem = [[NSMenuItem alloc] initWithTitle:item action:@selector(menuItemHandler:) keyEquivalent:@""];
+ }
else if([item isKindOfClass:[NSDictionary class]]) {
NSString *title = ([item objectForKey:@"title"]) ?: @"";
+
SEL action = ([item objectForKey:@"action"]) ? NSSelectorFromString([item objectForKey:@"action"]) : @selector(menuItemHandler:);
+
NSString *keyEquivalent = ([item objectForKey:@"key"]) ?: @"";
+
aMenuItem = [[NSMenuItem alloc] initWithTitle:title action:action keyEquivalent:keyEquivalent];
- if([item objectForKey:@"tooltip"])
+
+ if ([item objectForKey:@"tooltip"]) {
[aMenuItem setToolTip:[item objectForKey:@"tooltip"]];
+ }
}
+
[aMenuItem setTag:cnt++];
[theMenu addItem:aMenuItem];
[aMenuItem release];
}
+
[dialog setContextMenu:theMenu];
[dialog setFrameTopLeftPoint:location];
@@ -140,8 +150,8 @@
[[NSApplication sharedApplication] sendEvent:theEvent];
- while([dialog waitForChoice] && [[[NSApp keyWindow] firstResponder] isKindOfClass:[SPChooseMenuItemDialogTextView class]]) {
-
+ while ([dialog waitForChoice] && [[[NSApp keyWindow] firstResponder] isKindOfClass:[SPChooseMenuItemDialogTextView class]])
+ {
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantFuture]
inMode:NSDefaultRunLoopMode