diff options
| author | Tommaso Negri <me@tommasongr.com> | 2026-08-09 23:58:42 +0200 |
|---|---|---|
| committer | Tommaso Negri <me@tommasongr.com> | 2026-08-09 23:58:44 +0200 |
| commit | d59b22e557fa5d69ea6be725a7e5bcd829588225 (patch) | |
| tree | 618e20ef2b648e46eac3d51e14b8e0fcc1faba3c /Sources/phbar/Views/BlockView.swift | |
| parent | 62ce97dcb63d61c8db739c1b32bd387042ca66a0 (diff) | |
| download | bar-d59b22e557fa5d69ea6be725a7e5bcd829588225.tar.gz bar-d59b22e557fa5d69ea6be725a7e5bcd829588225.zip | |
rename project and add documentation guides
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 - } -} |
