Files
iOS/Sources/MacBridge/NSEvent+Additions.swift
Zac West 194cc154a7 Add menu to status item on right-click (#1420)
## Summary
Adds a basic menu structure to the status item. This includes:

- Toggling the app (e.g. activate or deactivate)
- Performing actions
- Opening About, Checking for Updates, opening Preferences and Quitting

## Screenshots
<img width="259" alt="Screen Shot 2021-01-24 at 22 51 24" src="https://user-images.githubusercontent.com/74188/105670916-b59cf580-5e96-11eb-9143-19ac5d4af92c.png"><img width="260" alt="Screen Shot 2021-01-24 at 22 51 16" src="https://user-images.githubusercontent.com/74188/105670921-b6ce2280-5e96-11eb-9c25-eddf4bb7ae12.png">

## Any other notes
There's not a clean way to do the left/right click handling. There's a few ways, all with their own pluses and negatives:
- Calling `popUpMenu(_:)` programmatically works, but it's marked as deprecated and it's tough to get Swift to not care.
- Handling `menuWillOpen` to instead do the left-click behavior and abort the menu display.
2021-01-25 15:26:56 -08:00

12 lines
289 B
Swift

import AppKit
extension NSEvent {
var isRightClickEquivalentEvent: Bool {
switch type {
case .rightMouseUp, .rightMouseDown: return true
case .leftMouseUp, .leftMouseDown: return modifierFlags.contains(.control)
default: return false
}
}
}