如何在swift / SwiftUI中以手势滑动菜单栏图标

我正在尝试获取一个小型测试应用程序,以便在向下滑动菜单栏图标时弹出带有swiftUI视图的迷你窗口。不用单击要弹出的窗口的按钮,而是用两根手指向下滑动,就像用户拉下要显示的窗口的图标一样。 我还是有点新手,但到目前为止,我在AppDelegate中拥有以下内容。

choices()

弹出窗口只是一个占位符文本视图,其中包含NBA球员的比赛统计信息。我在上面的代码中用 leftMouseDown 注释了 sendaction ,因为它工作得很好,但是当我将其更改为“ swipe ”时,作为 sendaction ,它什么也不做。我也尝试过' beginGesture ',' endGesture '和' gesture ',但是都没有用,最接近的成功是' leftMouseDragged ”,但不是我想要的。

如果使用的是问题,我正在使用SwiftUI,而不是使用故事板

iCMS 回答:如何在swift / SwiftUI中以手势滑动菜单栏图标

此方法有局限性,因为已记录此方法仅检查特定的掩码,而swipe则未检查。

> Declaration
> 
> func sendAction(on mask: NSEvent.EventTypeMask) -> Int Discussion
> 
> You use this method during mouse tracking when the mouse button
> changes state,the mouse moves,or if the cell is marked to send its
> action continuously while tracking. Because of this,the only bits
> checked in mask are NSLeftMouseDownMask,NSLeftMouseUpMask,> NSLeftMouseDraggedMask,and NSPeriodicMask,which are declared in the
> NSEvent class reference.
本文链接:https://www.f2er.com/1949223.html

大家都在问