The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > Omni Frameworks
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Improvement to OASteppableTextField Thread Tools Search this Thread Display Modes
I am using OASteppableTextField and would like to submit an improvement to it - not sure if there is some recommended way to do this, so will post the code here.

The issue: OASteppableTextField does not transform the values using a value transformer that may be attached to the binding.

Solution: look for either a transformer object or transformer name in the binding options and transform the value using it, if there is one. There are no API changes or side effects from this improvement. I have tested this fix and it works nicely. Would appreciate a note in the commit notes if you include this in a future version of the framework, so I don't have to remember to edit it each time.

Here is the revised method with comments at the start and end of the change:

- (BOOL)_stepWithFormatterSelector:(SEL)formatterSel ector;
{
NSFormatter *formatter = [self formatter];
if (![formatter respondsToSelector:formatterSelector])
return NO;

id objectValue = [formatter performSelector:formatterSelector withObject:[self objectValue]];
if (![self validateSteppedObjectValue:objectValue])
return NO;

[self setObjectValue:objectValue];
[NSApp sendAction:[self action] to:[self target] from:self];

NSDictionary *bindingInfo = [self infoForBinding:@"value"];
/****** START IMPROVEMENT *********/
if (bindingInfo) {
NSDictionary *bindingOptions = [bindingInfo objectForKey:NSOptionsKey];
if ([bindingOptions objectForKey:NSValueTransformerBindingOption]) {
NSValueTransformer *transformer = [bindingOptions objectForKey:NSValueTransformerBindingOption];
objectValue = [transformer reverseTransformedValue:objectValue];
} else if ([bindingOptions objectForKey:NSValueTransformerNameBindingOption]) {
NSValueTransformer *transformer = [NSValueTransformer valueTransformerForName:[bindingOptions objectForKey:NSValueTransformerNameBindingOption]];
objectValue = [transformer reverseTransformedValue:objectValue];
}

[[bindingInfo objectForKey:NSObservedObjectKey] setValue:objectValue forKeyPath:[bindingInfo objectForKey:NSObservedKeyPathKey]];
}
/********* END IMPROVEMENT **********/
return YES;
}
 
Thanks!

I've added this in a slightly more general fashion (a new utility function OAPushValueThroughBinding) and pushed it to github http://github.com/omnigroup/OmniGrou...85aa83050ac2d3
__________________
CTO, The Omni Group
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filters lil improvement mattao OmniPlan General 2 2011-08-25 01:35 PM
Mind Mapping Needs Improvement alphonso OmniGraffle General 3 2010-04-12 04:57 PM
OmniFocus improvement suggestions Guntis Applying OmniFocus 4 2009-03-04 07:22 PM
idea for improvement Huckla Forums Feedback 1 2009-02-25 08:03 AM
Speed improvement Handycam OmniWeb General 4 2008-07-14 11:49 AM


All times are GMT -8. The time now is 04:11 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.