开发者

Changing the content of a NSTextField via code when it's focused / gets edited by the user

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 t开发者_JAVA技巧his 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.

Changing the content of a NSTextField via code when it's focused / gets edited by the user

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜