2
struct Test: View {
    @State var text: String = ""
    
    var body: some View {
        ZStack {
            TextEditor(text: $text)
            
            Rectangle()
                .fill(Color.green)
                .padding()
                
        }.padding(50)
    }
}

Rectangle filled with green color displayed above the TextEditor. But even of this TextEditor changes mouse cursor to another one in case of mouse hovering Rectangle.

Question: Why? And how to fix?

I need:

  • default mouse cursor when I am hovering Rectangle.
  • "text-selectable" cursor on hovering TextEditor.

enter image description here

MacOS: Monteray 12.4 (21F79)

Xcode: 13.3 (13E113)

Ken White
  • 123,280
  • 14
  • 225
  • 444
Andrew_STOP_RU_WAR_IN_UA
  • 9,318
  • 5
  • 65
  • 101
  • You can disable TextEditor while it is covered with this green rectangle. – Asperi Jul 11 '22 at 17:11
  • @Asperi This is simplified sample. In original app textEditor is partially covered by another view and always must be enabled =( – Andrew_STOP_RU_WAR_IN_UA Jul 11 '22 at 17:14
  • This is long known problem and originated from [here](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html): "Mouse-moved events (type NSMouseMoved) are always sent to the first responder, not to the view under the mouse.". As far as I know there is no stable solution - NSTextView (which at backend) has always a priority. See for example [this](https://stackoverflow.com/q/32447739/12299030). – Asperi Jul 15 '22 at 17:18

0 Answers0