Improve loads of fancy things in relation to the mouse pointer

This commit is contained in:
2026-10-07 13:02:52 +02:00
parent ed5a227c9d
commit a0b3ef9975
25 changed files with 334 additions and 89 deletions
@@ -4,8 +4,6 @@ import AppKit
final class CodeTextView: PointerBoundTextView {
weak var controller: CodeEditorController?
/// Pointer travel that still counts as a click and not as a text selection.
private static let dragSlop: CGFloat = 4
private var pointerTracking: NSTrackingArea?
override func drawBackground(in rect: NSRect) {
@@ -20,14 +18,7 @@ final class CodeTextView: PointerBoundTextView {
override func mouseDown(with event: NSEvent) {
if event.modifierFlags.contains(.command), controller?.followSymbol(at: event) == true { return }
let hadSelection = selectedRange().length > 0
let down = event.locationInWindow
super.mouseDown(with: event)
guard event.clickCount == 1, !hadSelection, selectedRange().length == 0,
event.modifierFlags.isDisjoint(with: [.shift, .option, .command, .control]),
let up = window?.mouseLocationOutsideOfEventStream,
abs(up.x - down.x) + abs(up.y - down.y) <= Self.dragSlop else { return }
controller?.plainClick(atWindowPoint: down)
}
override func menu(for event: NSEvent) -> NSMenu? {