aboutsummaryrefslogtreecommitdiff
path: root/Sources/phbar/Views/BlockView.swift
diff options
context:
space:
mode:
authorTommaso Negri <me@tommasongr.com>2026-08-09 23:58:42 +0200
committerTommaso Negri <me@tommasongr.com>2026-08-09 23:58:44 +0200
commitd59b22e557fa5d69ea6be725a7e5bcd829588225 (patch)
tree618e20ef2b648e46eac3d51e14b8e0fcc1faba3c /Sources/phbar/Views/BlockView.swift
parent62ce97dcb63d61c8db739c1b32bd387042ca66a0 (diff)
downloadbar-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.swift60
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
- }
-}