diff options
Diffstat (limited to 'Sources/phbar/Views/BlockView.swift')
| -rw-r--r-- | Sources/phbar/Views/BlockView.swift | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/Sources/phbar/Views/BlockView.swift b/Sources/phbar/Views/BlockView.swift deleted file mode 100644 index 85d6e6e..0000000 --- a/Sources/phbar/Views/BlockView.swift +++ /dev/null @@ -1,60 +0,0 @@ -import SwiftUI - -struct BlockView: View { - @ObservedObject var block: Block - - @State private var hovering = false - - var body: some View { - HStack(spacing: 0) { - ForEach(block.cells) { cell in - CellView(cell: cell) - } - } - .onHover { hovering = $0 } - .onAppear { - NSEvent.addLocalMonitorForEvents(matching: [ - .leftMouseDown, - .rightMouseDown, - .otherMouseDown, - .scrollWheel, - ]) { event in - handle(event: event) - } - } - } - - private func handle(event: NSEvent) -> NSEvent { - guard hovering else { return event } - - switch event.type { - case .leftMouseDown, .rightMouseDown, .otherMouseDown: - block.runScript(env: ["BUTTON": String(event.buttonNumber)]) - break - case .scrollWheel: - if event.scrollingDeltaY > 0 { - block.runScript(env: ["SCROLL": "UP"]) - break - } - - if event.scrollingDeltaY < 0 { - block.runScript(env: ["SCROLL": "DOWN"]) - break - } - - if event.scrollingDeltaX > 0 { - block.runScript(env: ["SCROLL": "RIGHT"]) - break - } - - if event.scrollingDeltaX < 0 { - block.runScript(env: ["SCROLL": "LEFT"]) - break - } - default: - break - } - - return event - } -} |
