From: Michael M. <mic...@ma...> - 2005-02-28 02:25:06
|
On Feb 27, 2005, at 2:16 PM, Christiaan Hofman wrote: > Let me add a possibility to that: just subclass isEqualToString: in > BDSKComplexString. > Mike, as you understand those objects better, can you review this > proposal: > > - (BOOL)isEqualToString:(NSString *)aString{ > if ([aString isKindOfClass:[BDSKComplexString class]]) { > BDSKComplexString *aComplexString = (BDSKComplexString *)aString; > return [self isComplex] == [aComplexString isComplex] && > [[self nodesAsBibTeXString] isEqualToString:[aComplexString > nodesAsBibTeXString]]; > } else { > if ([self isComplex]) return NO; > return [expandedValue isEqualToString:aString]; > } > } > > I tried this and used this to check in > handleMacroTextFieldWindowWillCloseNotification: , and it seemed to > work: no undo and dirtying when I don't change the raw value. Sounds good. > Maybe we can also add a category for NSString that overwrites > isEqualToString:, returning YES if the argument is a simple complex > string with the same expanded string value (though I am not sure if > this works): > > - (BOOL)isEqualToString:(NSString *)aString{ > if ([aString isKindOfClass:[BDSKComplexString class]]) { > BDSKComplexString *aComplexString = (BDSKComplexString *)aString; > return ![aComplexString isComplex] && > [super isEqualToString:aString]; > } else { > return [super isEqualToString:aString]; > } > } I think we might only need to compare like this in the editor, and elsewhere just having the current behavior of isEqualToString: is probably OK (comparing the expanded value). Am I missing something here? I don't think I'm thinking too clearly about it right now. -mike > Christiaan > > > On Feb 27, 2005, at 23:40, Christiaan Hofman wrote: > >> I am trying to see how to avoid setting the undo (i.e. setting the >> field value) after edit as raw without changing. This is avoided in >> simple edit mode because there it is first checked if the string has >> changed. Could we do something like this in >> handleMacroTextFieldWindowWillCloseNotification: ? >> >> The problem is: how do we check if the string has changed? Maybe we >> need a method -isEqualToComplexString:, or change the isEqual: of >> BDSKComplexString to check against the raw bibtex string instead of >> the expanded value. Is it necessary that this checks the expanded >> value? Do I understand correctly that the value can be either a >> NSString or a BDSKComplexString? Then we might also have to deal with >> comparing those different objects intelligently? >> >> Christiaan |