New: grey out Edit menu non applicable items for text fields.

Copy, cut and delete are now disabled if there's no selection in the active text field. Cut, paste and delete are greyed out if the text field is not editable (a label).

Refs #1964.
This commit is contained in:
Alexander Ljungberg
2013-08-19 22:31:21 +01:00
parent 3fb12f6382
commit 08eff6ec22
+17
View File
@@ -1765,6 +1765,23 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
[self _becomeFirstKeyResponder];
}
- (BOOL)validateUserInterfaceItem:(id <CPValidatedUserInterfaceItem>)anItem
{
var theAction = [anItem action];
if (![self isEditable] && (theAction == @selector(cut:) || theAction == @selector(paste:) || theAction == @selector(delete:)))
return NO;
// FIXME - [self selectedRange] is always empty if we're not an editable field, so we must assume yes here.
if (![self isEditable])
return YES;
if (theAction == @selector(copy:) || theAction == @selector(cut:) || theAction == @selector(delete:))
return [self selectedRange].length;
return YES;
}
#pragma mark Private
- (BOOL)_isWithinUsablePlatformRect