diff --git a/AppKit/CPSearchField.j b/AppKit/CPSearchField.j index e6c12bfb4..ebdc86496 100644 --- a/AppKit/CPSearchField.j +++ b/AppKit/CPSearchField.j @@ -34,8 +34,7 @@ CPSearchFieldRecentsMenuItemTag = 1001; CPSearchFieldClearRecentsMenuItemTag = 1002; CPSearchFieldNoRecentsMenuItemTag = 1003; -var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotification", - RECENT_SEARCH_PREFIX = @" "; +var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotification"; /*! @ingroup appkit @@ -629,10 +628,10 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat for (var recentIndex = 0; recentIndex < countOfRecents; ++recentIndex) { - // RECENT_SEARCH_PREFIX is a hack until CPMenuItem -setIndentationLevel works - var recentItem = [[CPMenuItem alloc] initWithTitle:RECENT_SEARCH_PREFIX + [_recentSearches objectAtIndex:recentIndex] + var recentItem = [[CPMenuItem alloc] initWithTitle:[_recentSearches objectAtIndex:recentIndex] action:itemAction keyEquivalent:[item keyEquivalent]]; + [recentItem setIndentationLevel:1]; [item setTarget:self]; [menu addItem:recentItem]; } @@ -718,7 +717,7 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat - (void)_searchFieldSearch:(id)sender { - var searchString = [[sender title] substringFromIndex:[RECENT_SEARCH_PREFIX length]]; + var searchString = [sender title]; if ([sender tag] != CPSearchFieldRecentsMenuItemTag) [self _addStringToRecentSearches:searchString]; diff --git a/Tests/Manual/CPSearchField/AppController.j b/Tests/Manual/CPSearchField/AppController.j index 08796d492..78704d222 100644 --- a/Tests/Manual/CPSearchField/AppController.j +++ b/Tests/Manual/CPSearchField/AppController.j @@ -6,8 +6,7 @@ * Copyright 2010, Your Company All rights reserved. */ -var categories = ["firstName", "lastName"], - MenuItemPrefix = @" "; +var categories = ["firstName", "lastName"]; @implementation AppController : CPObject { @@ -40,18 +39,20 @@ var categories = ["firstName", "lastName"], keyEquivalent:@"" atIndex:0]; - var item = [[CPMenuItem alloc] initWithTitle:MenuItemPrefix + @"First Name" + var item = [[CPMenuItem alloc] initWithTitle:@"First Name" action:@selector(changeCategory:) keyEquivalent:@""]; - + [item setIndentationLevel:1]; [item setTarget:self]; [item setTag:1]; [item setState:CPOnState]; [searchMenuTemplate insertItem:item atIndex:1]; - item = [[CPMenuItem alloc] initWithTitle:MenuItemPrefix + @"Last Name" + item = [[CPMenuItem alloc] initWithTitle:@"Last Name" action:@selector(changeCategory:) keyEquivalent:@""]; + + [item setIndentationLevel:1]; [item setTarget:self]; [item setTag:2]; [item setState:CPOffState]; @@ -104,7 +105,7 @@ var categories = ["firstName", "lastName"], - (void)changeCategory:(CPMenuItem)menuItem { searchCategoryIndex = [menuItem tag] - 1; - [searchField setPlaceholderString:[[menuItem title] substringFromIndex:[MenuItemPrefix length]]]; + [searchField setPlaceholderString:[menuItem title]]; [self _updateSearchMenuTemplate]; }