Implemented context menu validation.

This commit is contained in:
Chhom Seng
2014-01-01 18:03:25 -07:00
parent 1bb753173a
commit ce838f6b7a

View File

@@ -469,6 +469,23 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
if(![document validateMenuItem:menuItem]) { if(![document validateMenuItem:menuItem]) {
return NO; return NO;
} }
// CS: don't know how to iterate through KPKEntry properties to check for blanks so just check the declared properties
KPKEntry *targetEntry = [self _clickedOrSelectedEntry];
MPActionType actionType = [MPActionHelper typeForAction:[menuItem action]];
if (([[targetEntry username] length] == 0) && (actionType == MPActionCopyUsername)) {
return NO;
}
if (([[targetEntry password] length] == 0) && (actionType == MPActionCopyPassword)) {
return NO;
}
if (([[targetEntry url] length] == 0) && (actionType == MPActionCopyURL || actionType == MPActionOpenURL)) {
return NO;
}
return YES; return YES;
/* TODO handle _clickedOrSlectedEnty */ /* TODO handle _clickedOrSlectedEnty */
} }