From b98dc4dc89367dd743d5c8e7e20ca481cc4ec58f Mon Sep 17 00:00:00 2001 From: mltownsend Date: Tue, 25 Aug 2009 23:07:20 +0000 Subject: Made it so that SPTableView and SPOutlineView will respond to enter or return being hit when a row is selected and go into edit mode. --- Interfaces/English.lproj/UserManagerView.xib | 150 ++++++++++----------------- Source/SPOutlineView.h | 33 ++++++ Source/SPOutlineView.m | 46 ++++++++ Source/SPTableView.m | 16 +++ Source/SPUserManager.m | 12 ++- 5 files changed, 156 insertions(+), 101 deletions(-) create mode 100644 Source/SPOutlineView.h create mode 100644 Source/SPOutlineView.m diff --git a/Interfaces/English.lproj/UserManagerView.xib b/Interfaces/English.lproj/UserManagerView.xib index 70f2b215..14760399 100644 --- a/Interfaces/English.lproj/UserManagerView.xib +++ b/Interfaces/English.lproj/UserManagerView.xib @@ -2,12 +2,13 @@ 1050 - 9J61 + 9L30 677 - 949.46 + 949.54 353.00 YES + YES @@ -74,14 +75,12 @@ 4352 {194, 467} - YES 256 {194, 17} - @@ -89,7 +88,6 @@ -2147483392 {{-26, 0}, {16, 17}} - YES @@ -189,7 +187,6 @@ {{0, 17}, {194, 467}} - @@ -200,7 +197,6 @@ -2147483392 {{246, 17}, {15, 308}} - _doScroller: 9.969040e-01 @@ -210,7 +206,6 @@ -2147483392 {{1, 325}, {245, 15}} - 1 _doScroller: @@ -225,7 +220,6 @@ {194, 17} - @@ -235,7 +229,6 @@ {{0, 22}, {194, 484}} - 560 @@ -255,7 +248,6 @@ 292 {{-1, -1}, {32, 24}} - YES 67239424 @@ -280,7 +272,6 @@ 292 {{30, -1}, {32, 24}} - YES 67239424 @@ -305,7 +296,6 @@ 292 {{61, -1}, {32, 24}} - YES -2076049856 @@ -380,7 +370,6 @@ {194, 23} - YES YES NO @@ -389,7 +378,6 @@ {194, 506} - NSView @@ -402,13 +390,12 @@ 274 {{13, 40}, {531, 460}} - YES General - + 256 YES @@ -537,6 +524,7 @@ {{10, 33}, {511, 414}} + General @@ -545,7 +533,7 @@ Global Privileges - + 274 YES @@ -569,7 +557,6 @@ 268 {{16, 72}, {133, 18}} - YES 67239424 @@ -597,7 +584,6 @@ 268 {{16, 52}, {133, 18}} - YES 67239424 @@ -618,12 +604,10 @@ {{1, 1}, {175, 98}} - {{252, 128}, {177, 114}} - {0, 0} 67239424 @@ -657,7 +641,6 @@ 268 {{16, 190}, {65, 18}} - YES 67239424 @@ -680,7 +663,6 @@ 268 {{16, 170}, {85, 18}} - YES 67239424 @@ -703,7 +685,6 @@ 268 {{16, 150}, {65, 18}} - YES 67239424 @@ -726,7 +707,6 @@ 268 {{16, 130}, {70, 18}} - YES 67239424 @@ -749,7 +729,6 @@ 268 {{16, 110}, {70, 18}} - YES 67239424 @@ -772,7 +751,6 @@ 268 {{16, 90}, {142, 18}} - YES 67239424 @@ -795,7 +773,6 @@ 268 {{16, 70}, {142, 18}} - YES 67239424 @@ -818,7 +795,6 @@ 268 {{16, 50}, {142, 18}} - YES 67239424 @@ -841,7 +817,6 @@ 268 {{16, 30}, {142, 18}} - YES 67239424 @@ -864,7 +839,6 @@ 268 {{16, 10}, {142, 18}} - YES 67239424 @@ -885,12 +859,10 @@ {{1, 1}, {231, 216}} - {{17, 10}, {233, 232}} - {0, 0} 67239424 @@ -914,7 +886,6 @@ 289 {{318, 84}, {114, 32}} - YES 67239424 @@ -945,7 +916,6 @@ 268 {{16, 92}, {63, 18}} - YES 67239424 @@ -968,7 +938,6 @@ 268 {{16, 72}, {63, 18}} - YES 67239424 @@ -991,7 +960,6 @@ 268 {{16, 52}, {67, 18}} - YES 67239424 @@ -1014,7 +982,6 @@ 268 {{16, 32}, {63, 18}} - YES 67239424 @@ -1037,7 +1004,6 @@ 268 {{16, 12}, {91, 18}} - YES 67239424 @@ -1060,7 +1026,6 @@ 268 {{152, 92}, {63, 18}} - YES 67239424 @@ -1083,7 +1048,6 @@ 268 {{152, 72}, {63, 18}} - YES 67239424 @@ -1106,7 +1070,6 @@ 268 {{152, 52}, {63, 18}} - YES 67239424 @@ -1129,7 +1092,6 @@ 268 {{152, 32}, {63, 18}} - YES 67239424 @@ -1150,12 +1112,10 @@ {{1, 1}, {231, 118}} - {{17, 246}, {233, 134}} - {0, 0} 67239424 @@ -1179,7 +1139,6 @@ 289 {{318, 52}, {114, 32}} - YES 67239424 @@ -1210,7 +1169,6 @@ 268 {{16, 92}, {97, 18}} - YES 67239424 @@ -1233,7 +1191,6 @@ 268 {{16, 72}, {97, 18}} - YES 67239424 @@ -1256,7 +1213,6 @@ 268 {{16, 52}, {116, 18}} - YES 67239424 @@ -1279,7 +1235,6 @@ 268 {{16, 32}, {105, 18}} - YES 67239424 @@ -1302,7 +1257,6 @@ 268 {{16, 12}, {97, 18}} - YES 67239424 @@ -1323,12 +1277,10 @@ {{1, 1}, {175, 118}} - {{252, 246}, {177, 134}} - {0, 0} 67239424 @@ -1350,13 +1302,10 @@ {{17, 11}, {446, 400}} - NSView {{10, 33}, {511, 414}} - - Global Privileges @@ -1636,13 +1585,13 @@ - + 0 YES YES - + @@ -1650,7 +1599,6 @@ 289 {{467, 12}, {76, 32}} - YES -2080244224 @@ -1672,7 +1620,6 @@ 289 {{385, 12}, {82, 32}} - YES -2080244224 @@ -1692,20 +1639,17 @@ {{195, 0}, {557, 506}} - NSView {752, 506} - YES 2 {752, 506} - {{0, 0}, {1920, 1178}} {3.40282e+38, 3.40282e+38} @@ -1949,37 +1893,6 @@ 436 - - - value: selection.user - - - - - - value: selection.user - value - selection.user - - YES - - YES - NSNoSelectionPlaceholder - NSNotApplicablePlaceholder - NSRaisesForNotApplicableKeys - - - YES - No Selection - User Not Selected - - - - 2 - - - 446 - delegate @@ -2546,6 +2459,37 @@ 606 + + + value: selection.user + + + + + + value: selection.user + value + selection.user + + YES + + YES + NSNoSelectionPlaceholder + NSNotApplicablePlaceholder + NSRaisesForNotApplicableKeys + + + YES + No Selection + User Not Selected + + + + 2 + + + 608 + @@ -3494,6 +3438,7 @@ 3.IBWindowTemplateEditedContentRect 3.NSWindowTemplate.visibleAtLaunch 30.IBPluginDependency + 31.CustomClassName 31.IBPluginDependency 33.IBPluginDependency 36.IBPluginDependency @@ -3608,13 +3553,14 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{59, 255}, {752, 506}} + {{73, 350}, {752, 506}} com.apple.InterfaceBuilder.CocoaPlugin - {{59, 255}, {752, 506}} + {{73, 350}, {752, 506}} com.apple.InterfaceBuilder.CocoaPlugin + SPOutlineView com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3745,7 +3691,7 @@ - 606 + 608 @@ -3796,6 +3742,14 @@ Source/SPWindowAdditions.h + + SPOutlineView + NSOutlineView + + IBProjectSource + Source/SPOutlineView.h + + SPUserManager NSWindowController diff --git a/Source/SPOutlineView.h b/Source/SPOutlineView.h new file mode 100644 index 00000000..c361f788 --- /dev/null +++ b/Source/SPOutlineView.h @@ -0,0 +1,33 @@ +// +// $Id: SPUserManager.m 856 2009-06-12 05:31:39Z mltownsend $ +// +// SPOutlineView.h +// sequel-pro +// +// Created by Mark Townsend on Aug 25, 2009 +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + + +#import + + +@interface SPOutlineView : NSOutlineView { + +} + +@end diff --git a/Source/SPOutlineView.m b/Source/SPOutlineView.m new file mode 100644 index 00000000..97f8cab3 --- /dev/null +++ b/Source/SPOutlineView.m @@ -0,0 +1,46 @@ +// +// $Id: SPUserManager.m 856 2009-06-12 05:31:39Z mltownsend $ +// +// SPOutlineView.m +// sequel-pro +// +// Created by Mark Townsend on Aug 25, 2009 +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + + +#import "SPOutlineView.h" + + +@implementation SPOutlineView + +- (BOOL)acceptsFirstResponder +{ + return YES; +} + +-(void)keyDown:(NSEvent *)theEvent +{ + if([self numberOfSelectedRows] == 1 && ([theEvent keyCode] == 36 || [theEvent keyCode] == 76)) + { + [self editColumn:0 row:[self selectedRow] withEvent:nil select:YES]; + } + else { + [super keyDown:theEvent]; + } +} +@end diff --git a/Source/SPTableView.m b/Source/SPTableView.m index bff7a923..f6af2c16 100644 --- a/Source/SPTableView.m +++ b/Source/SPTableView.m @@ -54,4 +54,20 @@ return [self menu]; } +-(BOOL)acceptsFirstResponder +{ + return YES; +} + +- (void)keyDown:(NSEvent *)theEvent +{ + if([self numberOfSelectedRows] == 1 && ([theEvent keyCode] == 36 || [theEvent keyCode] == 76)) + { + [self editColumn:0 row:[self selectedRow] withEvent:nil select:YES]; + } + else { + [super keyDown:theEvent]; + } +} + @end diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index dbac9ea2..44f499be 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -407,7 +407,10 @@ [treeController addChild:sender]; // Need to figure out how to do this right. I want to be able to have the newly // added item be in edit mode to change the host name. -// [outlineView editColumn:0 row:[outlineView selectedRow] withEvent:nil select:TRUE]; + NSLog(@"selectedRow: %d", [outlineView selectedRow]); + NSIndexPath *indexPath = [treeController selectionIndexPath]; + NSLog(@"selectedChild: %d", [indexPath indexAtPosition:[outlineView selectedRow]]); + [outlineView editColumn:0 row:[outlineView selectedRow] withEvent:nil select:TRUE]; } - (IBAction)removeHost:(id)sender @@ -425,11 +428,14 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { - if ([menuItem action] == @selector(addHost:) || - [menuItem action] == @selector(removeHost:)) + if ([menuItem action] == @selector(removeHost:)) { return (([[treeController selectedObjects] count] > 0) && [[[treeController selectedObjects] objectAtIndex:0] parent] != nil); + } + else if ([menuItem action] == @selector(addHost:)) + { + return ([[treeController selectedObjects] count] > 0); } return TRUE; } -- cgit v1.2.3