gpt4 book ai didi

macos - 通过左键单击 macOS 触发 SwiftUI 上下文菜单

转载 作者:行者123 更新时间:2023-12-04 03:39:28 24 4
gpt4 key购买 nike

我的 View 上有一个齿轮按钮,当用户单击它时,我想显示一个按钮菜单。看来https://developer.apple.com/documentation/swiftui/view/contextmenu(menuitems:)专为此任务而设计,但只有右键单击才能触发上下文菜单。
如何触发 contextMenu通过左键单击 macOS?谢谢!

最佳答案

您可以为该类型的 UI 使用特定的菜单样式。如果您想隐藏指标,只需输入 false。

Menu("Label") {
Button("Buttons") { }
}
.menuStyle(BorderlessButtonMenuStyle(showsMenuIndicator: true))
.fixedSize() // Otherwise will be the width of your menu options.

关于macos - 通过左键单击 macOS 触发 SwiftUI 上下文菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66317667/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com