Secure-Text-Field-Like Field Editor Initialization
Secure-Text-Field-Like Field Editor Initialization
- Subject: Secure-Text-Field-Like Field Editor Initialization
- From: Zachary Ullevig <email@hidden>
- Date: Sat, 4 Aug 2007 12:42:11 -0600
- Resent-date: Sat, 4 Aug 2007 19:50:02 -0600
- Resent-from: Zachary Ullevig <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
I have a requirement to handle user entry in an NSTableView with one
column behaving similarly to a secure text field in that the data
displayed is not the same as the object the cell actually represents.
I have created a custom field editor which handles the user input and
underlying object update correctly, but I am having trouble with
initializing the custom field editor's displayed string value. I
don't think I am fully understanding how a field editor is
initialized with the cell data it is editing.
If I assign the desired display string to the field editor within
windowWillReturnFieldEditor, the string appears as desired when the
field editor is displayed, but the string is constantly re-assigned
to the field editor in response to various events. If I assign the
desired display string to the field editor within
setUpFieldEditorAttributes, the string is stored in the custom field
editor within that method's scope, but at some point before the field
editor is displayed, the string is replaced with the string from the
cell's objectValue.
I believe both locations are the wrong place to assign the display
string value, but I have been unable to find where it should go.
Hopefully I have all the relevant code snippets included below. Does
anyone have some insights on what I might be doing wrong?
@implementation MyDocument
...
-(id)windowWillReturnFieldEditor:(NSWindow *)theSender toObject:(id)
theObject {
if ([theObject isKindOfClass:[NSTableView class]]) {
CustomFieldEditor * aFieldEditor = [CustomFieldEditor
singletonInstance];
[aFieldEditor setFieldEditor:YES];
[aFieldEditor setDelegate:self];
//
// if I call [aFieldEditor setString:] here, the string is
assigned to the editor,
// it is displayed on screen correctly, but the string gets
re-assigned to the
// field editor repeatedly and often at undesirable times
//
return aFieldEditor;
}
return nil;
}
...
@end
@implementation MyCustomCell
...
- (NSText *)setUpFieldEditorAttributes:(NSText *)theFieldEditor {
theFieldEditor = [super setUpFieldEditorAttributes:theFieldEditor];
[theFieldEditor setFieldEditor:YES];
// I confirmed the custom editor class is being passed in...
NSLog( @"FIELD EDITOR CLASS: %@", [theFieldEditor class] );
//
// custom field attributes initialized here
//
//
// if I call [theFieldEditor setString:] here, the string is
assigned to the editor,
// but the string is replaced with the cell's objectValue string
by the time the
// field editor is displayed to the screen
//
return theFieldEditor;
}
...
@end
@implementation MyCustomFieldEditor
static id myInstance = nil;
+(id)singletonInstance {
if( myInstance == nil ) {
myInstance = [[MyCustomFieldEditor alloc] init];
}
return myInstance;
}
- (id) init {
self = [super init];
if( self != nil ) {
}
return self;
}
...
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden