@@ -326,6 +326,16 @@ public class TextView: NSView, NSTextContent {
326326 super. canBecomeKeyView && acceptsFirstResponder && !isHiddenOrHasHiddenAncestor
327327 }
328328
329+ /// Sent to the window's first responder when `NSWindow.makeKey()` occurs.
330+ @objc private func becomeKeyWindow( ) {
331+ _ = becomeFirstResponder ( )
332+ }
333+
334+ /// Sent to the window's first responder when `NSWindow.resignKey()` occurs.
335+ @objc private func resignKeyWindow( ) {
336+ _ = resignFirstResponder ( )
337+ }
338+
329339 open override var needsPanelToBecomeKey : Bool {
330340 isSelectable || isEditable
331341 }
@@ -362,6 +372,23 @@ public class TextView: NSView, NSTextContent {
362372 updateFrameIfNeeded ( )
363373 }
364374
375+ // MARK: - Hit test
376+
377+ /// Returns the responding view for a given point.
378+ /// - Parameter point: The point to find.
379+ /// - Returns: A view at the given point, if any.
380+ override public func hitTest( _ point: NSPoint ) -> NSView ? {
381+ // For our purposes, cursor and line fragment views should be transparent from the point of view of
382+ // all other views. So, if the normal hitTest returns one of them, we return `self` instead.
383+ let hitView = super. hitTest ( point)
384+
385+ if let hitView, hitView != self ,
386+ type ( of: hitView) == CursorView . self || type ( of: hitView) == LineFragmentView . self {
387+ return self
388+ }
389+ return hitView
390+ }
391+
365392 // MARK: - Key Down
366393
367394 override public func keyDown( with event: NSEvent ) {
@@ -381,6 +408,15 @@ public class TextView: NSView, NSTextContent {
381408
382409 // MARK: - Layout
383410
411+ open override class var isCompatibleWithResponsiveScrolling : Bool {
412+ true
413+ }
414+
415+ open override func prepareContent( in rect: NSRect ) {
416+ needsLayout = true
417+ super. prepareContent ( in: rect)
418+ }
419+
384420 override public func draw( _ dirtyRect: NSRect ) {
385421 super. draw ( dirtyRect)
386422 if isSelectable {
0 commit comments