Skip to content

Color.clear overlay in PaneContainerView blocks AppKit cursor events #4

@dafanasev1986

Description

@dafanasev1986

Problem

PaneContainerView places a Color.clear overlay above all pane content in the ZStack (dropZonesLayer method). This overlay has .onTapGesture and .onDrop modifiers, which causes it to intercept all mouse events before they reach any AppKit views hosted via NSViewRepresentable underneath.

This breaks AppKit's cursor rect management — for example, NSTableView column header resize cursors never appear because the invisible SwiftUI layer sits on top and blocks the events.

Location

https://github.com/almonk/bonsplit/blob/main/Sources/Bonsplit/Internal/Views/PaneContainerView.swift#L114-L126

@ViewBuilder
private func dropZonesLayer(size: CGSize) -> some View {
    Color.clear
        .onTapGesture {
            controller.focusPane(pane.id)
        }
        .onDrop(of: [.text], delegate: UnifiedPaneDropDelegate(
            size: size,
            pane: pane,
            controller: controller,
            activeDropZone: $activeDropZone
        ))
}

Fix

Remove the separate Color.clear overlay and apply .onTapGesture and .onDrop directly to contentArea:

ZStack {
    contentArea
        .onTapGesture {
            controller.focusPane(pane.id)
        }
        .onDrop(of: [.text], delegate: UnifiedPaneDropDelegate(
            size: size,
            pane: pane,
            controller: controller,
            activeDropZone: $activeDropZone
        ))

    dropPlaceholder(for: activeDropZone, in: size)
        .allowsHitTesting(false)
}

This preserves tap-to-focus and tab drag-and-drop while allowing AppKit cursor events to pass through to hosted NSViewRepresentable views.

The dropZonesLayer method can then be removed entirely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions