문제

I have a NSSlider which updates the content of an NSTextField. So far so good. It works as long as the NSTextField isn't focused or gets edited by the user (typing or staying blank etc.).

What I'm trying to get working is to force the update of the NSTextField via code, no matter what the user is doing.

That's the code of the slider changed value event:

-(IBAction) sliderTempoMoved: (id)sender{
[soundEngine setTempo:[sender floatValue]];

[labelTempo setStringValue:[NSString stringWithFormat:@"%0.2f%",[sender floatValue]]];
 NSLog(@"slideTempoMoved: %f",[sender floatValue]);
}

The setStringValue method works as long as the NSTextField doesn't get edited...

Any clues on this problem ??

Regards, Alex

도움이 되었습니까?

해결책

I don't know how much help this is, but I tried your code and the NSTextField gets updated whether or not it's currently being edited. Check your NSTextField properties against mine. Maybe something there is keeping it from being updated.

You could also try calling [labelTempo abortEditing] before the call to setStringValue.

NSTextField Properties

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