美文网首页Mac
NSSlider 拖动开始,结束,拖动中事件

NSSlider 拖动开始,结束,拖动中事件

作者: yxibng | 来源:发表于2020-02-15 17:20 被阅读0次

    参考# Determine when NSSlider knob is 'let go' in continuous mode

    - (IBAction)sizeSliderValueChanged:(id)sender {
        NSEvent *event = [[NSApplication sharedApplication] currentEvent];
        BOOL startingDrag = event.type == NSLeftMouseDown;
        BOOL endingDrag = event.type == NSLeftMouseUp;
        BOOL dragging = event.type == NSLeftMouseDragged;
    
        NSAssert(startingDrag || endingDrag || dragging, @"unexpected event type caused slider change: %@", event);
    
        if (startingDrag) {
            NSLog(@"slider value started changing");
            // do whatever needs to be done when the slider starts changing
        }
    
        // do whatever needs to be done for "uncommitted" changes
        NSLog(@"slider value: %f", [sender doubleValue]);
    
        if (endingDrag) {
            NSLog(@"slider value stopped changing");
            // do whatever needs to be done when the slider stops changing
        }
    }
    

    相关文章

      网友评论

        本文标题:NSSlider 拖动开始,结束,拖动中事件

        本文链接:https://www.haomeiwen.com/subject/dvdyfhtx.html