mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Add two-way binding support to OakEncodingPopUpButton
Previously binding to the view’s encoding property would not update the bound object when the view changed its value.
This commit is contained in:
@@ -215,6 +215,20 @@ namespace // PopulateMenu{Flat,Hierarchical}
|
||||
if(_encoding && ![self.availableEncodings containsObject:_encoding])
|
||||
[self updateAvailableEncodings];
|
||||
[self updateMenu];
|
||||
|
||||
if(NSDictionary* info = [self infoForBinding:@"encoding"])
|
||||
{
|
||||
id controller = info[NSObservedObjectKey];
|
||||
NSString* keyPath = info[NSObservedKeyPathKey];
|
||||
if(controller && controller != [NSNull null] && keyPath && (id)keyPath != [NSNull null])
|
||||
{
|
||||
NSString* newValue = _encoding;
|
||||
|
||||
NSString* oldValue = [controller valueForKeyPath:keyPath];
|
||||
if(!oldValue || ![oldValue isEqualToString:newValue])
|
||||
[controller setValue:newValue forKeyPath:keyPath];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setAvailableEncodings:(NSArray*)newEncodings
|
||||
|
||||
Reference in New Issue
Block a user