Revision: 27431
http://sourceforge.net/p/bibdesk/svn/27431
Author: hofman
Date: 2022-05-18 15:16:25 +0000 (Wed, 18 May 2022)
Log Message:
-----------
separate method to abort editing a text field
Modified Paths:
--------------
trunk/bibdesk/BDSKEditor.m
Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m 2022-05-18 15:09:57 UTC (rev 27430)
+++ trunk/bibdesk/BDSKEditor.m 2022-05-18 15:16:25 UTC (rev 27431)
@@ -363,6 +363,17 @@
return rv;
}
+- (void)abortEditingControl:(NSControl *)control atRow:(NSInteger)row {
+ [control abortEditing];
+ if (row != -1) {
+ // controlTextDidEndEditing: is not called when calling abortEditing
+ [tableCellFormatter setEditAsComplexString:NO];
+ // restore the value,in case it was inherited
+ [control setObjectValue:[publication valueOfField:[fields
objectAtIndex:row]] ?: @""];
+ }
+ [self setEditing:NO];
+}
+
- (void)discardEditing
{
id firstResponder = [[self window] firstResponder];
@@ -385,13 +396,7 @@
// may be self, if a textview was being edited (but we should have
taken the first branch in that case)
if ([control respondsToSelector:@selector(abortEditing)]) {
- [control abortEditing];
- NSInteger row = [tableView rowForView:control];
- if (row != -1) {
- // controlTextDidEndEditing: is not called when calling
abortEditing
- [tableCellFormatter setEditAsComplexString:NO];
- [control setObjectValue:[publication valueOfField:[fields
objectAtIndex:row]] ?: @""];
- }
+ [self abortEditingControl:control atRow:[tableView
rowForView:control]];
}
else {
fprintf(stderr, "%s, control does not respond to
abortEditing\n", __func__);
@@ -2261,12 +2266,7 @@
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView
doCommandBySelector:(SEL)commandSelector {
NSInteger row = [tableView rowForView:control];
if (commandSelector == @selector(cancelOperation:)) {
- [control abortEditing];
- [self setEditing:NO];
- if (row != -1) {
- [tableCellFormatter setEditAsComplexString:NO];
- [control setObjectValue:[publication valueOfField:[fields
objectAtIndex:row]] ?: @""];
- }
+ [self abortEditingControl:control atRow:row];
return YES;
} else if (row == -1) {
return NO;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit