如何在ObjectiveC OSX中使用NSPageController禁用NSTableView的滚动事件?

只是一个编码员

我有一个NSPageController-控制器,使用户可以在视图之间水平滑动。

问题在于,在我们要滑动的视图上有一个视图NSTableView那时,我无法滑动回到以前的视图,因为该按钮NSTableView正在“吃掉”所有滑动手势。有谁知道如何禁用上的水平滚动,NSTableView以便水平滑动手势可以转到NSPageController而不是表格的视图

只是一个编码员

使用以下NSScrollView的自定义类实现在Swift中解决

class HorizontalScrollDisabledTable: NSScrollView {
    var currentScrollIsHorizontal: Bool = true;

    override func scrollWheel(theEvent: NSEvent) {

        var phase: NSEventPhase = theEvent.phase

        /* Ensure that both scrollbars are flashed when the user taps trackpad with two fingers */
        if (phase == .MayBegin) {
            super.scrollWheel(theEvent) ;
            self.nextResponder?.scrollWheel(theEvent);
            return;
        }
        /* Check the scroll direction only at the beginning of a gesture for modern scrolling devices */
        /* Check every event for legacy scrolling devices */
        if (phase == .Began || (phase == .None && theEvent.momentumPhase == .None)) {
            currentScrollIsHorizontal = fabs(theEvent.scrollingDeltaX) > fabs(theEvent.scrollingDeltaY);
        }
        if (!currentScrollIsHorizontal ) {
            super.scrollWheel(theEvent);
        } else {
            self.nextResponder!.scrollWheel(theEvent);
        }
    }
}

这是上面的scrollWheel方法的相同答案的代码,但在ObjectiveC中。

-(void)scrollWheel:(NSEvent *)theEvent {

    NSEventPhase phase = [theEvent phase];

    /* Ensure that both scrollbars are flashed when the user taps trackpad with two fingers */
    if (phase == NSEventPhaseMayBegin) {
        [super scrollWheel:theEvent];
        [self.nextResponder scrollWheel:theEvent];
            return;
    }
    /* Check the scroll direction only at the beginning of a gesture for modern scrolling devices */
    /* Check every event for legacy scrolling devices */
    if (phase == NSEventPhaseBegan || (phase == NSEventPhaseNone && theEvent.momentumPhase == NSEventPhaseNone)) {
        currentScrollIsHorizontal = fabs(theEvent.scrollingDeltaX) > fabs(theEvent.scrollingDeltaY);
    }
    if (!currentScrollIsHorizontal ) {
        [super scrollWheel:theEvent];
    } else {
        [self.nextResponder scrollWheel:theEvent];
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在terminalrc文件中使用选项禁用xfce4-terminal的滚动条?

来自分类Dev

如何在CDI事件中使用参数?

来自分类Dev

如何在Yii事件中使用交易

来自分类Dev

如何在AngularJS中使用Keydown事件

来自分类Dev

如何在Yii事件中使用交易

来自分类Dev

如何在onmouseleave事件中使用RGBA?

来自分类Dev

如何在qml中使用SwipeView的事件?

来自分类Dev

ObjectiveC-如何使用NSUserNotification标识符属性

来自分类Dev

如何在SWT中使用鼠标滚轮滚动滚动的合成

来自分类Dev

jQuery如何在单击另一个事件时禁用滚动事件

来自分类Dev

在Mac的Safari中使用Ctrl + Click时,如何从contextmenu事件中禁用click事件?

来自分类Dev

如何在jQuery中使用onchange事件触发datarangepicker事件?

来自分类Dev

如何在ObjectiveC中为浮动的UIView设置动画

来自分类Dev

如何在ObjectiveC中检查键值观察数组的字典?

来自分类Dev

如何在ObjectiveC中检查键值观察数组的字典?

来自分类Dev

如何在Delphi中使用Apple OSX API?

来自分类Dev

如何在OSX应用程序中使用Core Bluetooth?

来自分类Dev

如何在Mac OSX的SED中使用PCRE Regex

来自分类常见问题

如何在Flutter中使用SingleChildScrollView使ListView滚动

来自分类Dev

我如何在熊猫滚动中使用apply_corr()

来自分类Dev

如何在活动中使用滚动视图创建多行edittext?

来自分类Dev

如何在R中使用滚动变量构建序列

来自分类Dev

如何在Python中使用Selenium chromedriver水平滚动

来自分类Dev

如何在python中使用硒在div中“向上滚动”?

来自分类Dev

如何在Dart中使用数据绑定禁用按钮?

来自分类Dev

如何在rspec中使用sidekiq禁用警告消息

来自分类Dev

如何在实现CSS中使用jQuery禁用按钮

来自分类Dev

如何在bazel中使用配置设置启用/禁用属性?

来自分类Dev

如何在yii中使用jQuery禁用按钮

Related 相关文章

  1. 1

    如何在terminalrc文件中使用选项禁用xfce4-terminal的滚动条?

  2. 2

    如何在CDI事件中使用参数?

  3. 3

    如何在Yii事件中使用交易

  4. 4

    如何在AngularJS中使用Keydown事件

  5. 5

    如何在Yii事件中使用交易

  6. 6

    如何在onmouseleave事件中使用RGBA?

  7. 7

    如何在qml中使用SwipeView的事件?

  8. 8

    ObjectiveC-如何使用NSUserNotification标识符属性

  9. 9

    如何在SWT中使用鼠标滚轮滚动滚动的合成

  10. 10

    jQuery如何在单击另一个事件时禁用滚动事件

  11. 11

    在Mac的Safari中使用Ctrl + Click时,如何从contextmenu事件中禁用click事件?

  12. 12

    如何在jQuery中使用onchange事件触发datarangepicker事件?

  13. 13

    如何在ObjectiveC中为浮动的UIView设置动画

  14. 14

    如何在ObjectiveC中检查键值观察数组的字典?

  15. 15

    如何在ObjectiveC中检查键值观察数组的字典?

  16. 16

    如何在Delphi中使用Apple OSX API?

  17. 17

    如何在OSX应用程序中使用Core Bluetooth?

  18. 18

    如何在Mac OSX的SED中使用PCRE Regex

  19. 19

    如何在Flutter中使用SingleChildScrollView使ListView滚动

  20. 20

    我如何在熊猫滚动中使用apply_corr()

  21. 21

    如何在活动中使用滚动视图创建多行edittext?

  22. 22

    如何在R中使用滚动变量构建序列

  23. 23

    如何在Python中使用Selenium chromedriver水平滚动

  24. 24

    如何在python中使用硒在div中“向上滚动”?

  25. 25

    如何在Dart中使用数据绑定禁用按钮?

  26. 26

    如何在rspec中使用sidekiq禁用警告消息

  27. 27

    如何在实现CSS中使用jQuery禁用按钮

  28. 28

    如何在bazel中使用配置设置启用/禁用属性?

  29. 29

    如何在yii中使用jQuery禁用按钮

热门标签

归档