Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top