문제

I have an NSColorWell, which is bound to a property that contains an NSString instance, which get's transformed into an NSColor through my ColorTransformer (NSValueTransformer). It essentially transforms something like #FF0000 into an NSColor. This works as expected, but the ColorWell no longer opens it's Pane when clicked. When I disable the binding, it works again. Any clues to what I'm doing wrong here?

도움이 되었습니까?

해결책

return YES in

+(BOOL)allowsReverseTransformation

the apple docs example has it return NO, however the default implementation has it return YES. The reasoning behind this is in theory simple enough: apple doesn't want your users to be able to set a color which will then crash the app (being that a reverse transform was not implemented). You should then probably implement

- (id)reverseTransformedValue:(id)value

to make sure this doesn't happen, if you haven't done so already. (If you don't apple's docs say it will call - (id)transformedValue:(id)value)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top