fixes cursor
This commit is contained in:
@@ -54,9 +54,8 @@ final class CodeTextView: PointerBoundTextView {
|
||||
|
||||
override func flagsChanged(with event: NSEvent) {
|
||||
super.flagsChanged(with: event)
|
||||
let command = event.modifierFlags.contains(.command)
|
||||
controller?.commandKeyChanged(command)
|
||||
if let window { updatePointer(at: window.mouseLocationOutsideOfEventStream, command: command) }
|
||||
controller?.commandKeyChanged(event.modifierFlags.contains(.command))
|
||||
if let point = mouseLocation, isTopmost(atWindowPoint: point) { updatePointer(atWindowPoint: point) }
|
||||
}
|
||||
|
||||
override func updateTrackingAreas() {
|
||||
@@ -67,23 +66,12 @@ final class CodeTextView: PointerBoundTextView {
|
||||
pointerTracking = area
|
||||
}
|
||||
|
||||
override func mouseMoved(with event: NSEvent) {
|
||||
super.mouseMoved(with: event)
|
||||
updatePointer(at: event.locationInWindow, command: event.modifierFlags.contains(.command))
|
||||
}
|
||||
|
||||
override func cursorUpdate(with event: NSEvent) {
|
||||
super.cursorUpdate(with: event)
|
||||
updatePointer(at: event.locationInWindow, command: event.modifierFlags.contains(.command))
|
||||
}
|
||||
|
||||
/// The pointing hand over a symbol ⌘-click would follow, the I-beam elsewhere in the text.
|
||||
private func updatePointer(at windowPoint: NSPoint, command: Bool) {
|
||||
guard visibleRect.contains(convert(windowPoint, from: nil)) else { return }
|
||||
if command, controller?.symbol(atWindowPoint: windowPoint) != nil {
|
||||
/// The pointing hand over a symbol ⌘-click would follow, else the policy's pointer.
|
||||
override func applyPointer(_ shape: PointerShape, atWindowPoint point: NSPoint) {
|
||||
if shape == .iBeam, NSEvent.modifierFlags.contains(.command), controller?.symbol(atWindowPoint: point) != nil {
|
||||
NSCursor.pointingHand.set()
|
||||
} else {
|
||||
NSCursor.iBeam.set()
|
||||
shape.cursor.set()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user