diff options
Diffstat (limited to 'src/macos/Sources')
| -rw-r--r-- | src/macos/Sources/PardesView.swift | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/macos/Sources/PardesView.swift b/src/macos/Sources/PardesView.swift index 4ea4475a..b51f6719 100644 --- a/src/macos/Sources/PardesView.swift +++ b/src/macos/Sources/PardesView.swift @@ -2652,22 +2652,26 @@ final class PardesView: NSView { // .inVisibleRect keeps the area correct across resizes on its own, which // is why the rect argument can be anything. addTrackingArea(NSTrackingArea(rect: .zero, - options: [.mouseMoved, .mouseEnteredAndExited, .inVisibleRect, .activeInKeyWindow], + options: [.mouseMoved, .mouseEnteredAndExited, .cursorUpdate, .inVisibleRect, .activeInKeyWindow], owner: self, userInfo: nil)) } - private enum Pointer: Equatable { case text, link, target } + private enum Pointer: Equatable { case text, link, target, grab, dragging, resizeHorizontal, resizeVertical } private var pointer: Pointer = .text /// The core's pointer_shape, in this shell's cursor vocabulary: a link /// is a PDF hyperlink (the hand), a target is a word the core's own /// Look-hover plumbing validated as a real Look or Exec operand, and - /// anything else is text — the I-beam. + /// grips and dividers carry the native drag/resize affordances. private func pointerShape() -> Pointer { switch pardes_pointer_shape() { case 1: return .link case 2: return .target + case 3: return .dragging + case 4: return .grab + case 5: return .resizeHorizontal + case 6: return .resizeVertical default: return .text } } @@ -2677,14 +2681,21 @@ final class PardesView: NSView { case .link: return .pointingHand case .target: return .arrow case .text: return .iBeam + case .grab: return .openHand + case .dragging: return .closedHand + case .resizeHorizontal: return .resizeLeftRight + case .resizeVertical: return .resizeUpDown } } + override func cursorUpdate(with event: NSEvent) { + pointer = pointerShape() + cursorFor(pointer).set() + } + override func resetCursorRects() { - // Every cell in this view is text, including the tags. An arrow over - // plain text is the wrong affordance — but a word the core has - // validated as a Look or Exec target earns it: middle- and - // right-clicking there acts, and the cursor says so before it does. + // AppKit may reset cursor rectangles between frames. Keep the current + // text, target, grip or drag affordance instead of resetting to I-beam. addCursorRect(bounds, cursor: cursorFor(pointer)) } |
