NSSlider 循环

发布于 2025-01-06 03:23:08 字数 147 浏览 4 评论 0原文

我正在我的项目中建立一个 NSSlider,当向上或向下移动时需要调用不同的方法。因此,如果向上移动,它将执行一种方法,即一个 AppleScript,如果向另一个方向移动,则执行相反的操作,即另一个 AppleScript。我会用 IF 循环还是其他东西来做到这一点?提前致谢!

I am instituting a NSSlider into my project that needs to call different methods when moved up or down. So if it is moved up it will do one method, which is a AppleScript, and the opposite if moved in the other direction, another AppleScript. Would I do this with an IF loop or something else? Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘过的浮云 2025-01-13 03:23:08

您应该跟踪滑块的旧值,然后与新值进行比较,看看它是向下还是向上移动。

- (IBAction)slide:(id)sender {
    float newValue = [slider floatValue];
    if (newValue < oldValue) {
        // moved down
    } else {
        // moved up
    }
    oldValue = newValue;
}

you should keep track of the old value of the slider, and then compare with the new one to see if it has moved down or up.

- (IBAction)slide:(id)sender {
    float newValue = [slider floatValue];
    if (newValue < oldValue) {
        // moved down
    } else {
        // moved up
    }
    oldValue = newValue;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文