MrSunshine
MrSunshine

Reputation: 1

How to make TextEdit untapable but scrollable in SwiftUI

I have a TextEditor, which is covered by another View in ZStack:

ZStack {
  TextEditor()
  MyView()
}

The idea that I have 2 modes: edit and view. In edit view I remove MyView from ZStack. In view mode I cover TextEditor with MyView - its just transparent fullscreen VStack with onTapGesture.

So in view mode when I tap on MyView, my TextEditor receives this tap and gets focused. My goal is to process tap only in MyView.

One possible solution is to make TextEditor .disabled, but in this case it becomes unscrollable. Another option is to pass to TextEditor .constant data, but it anyway remains tapable and focusable.

I want to achieve this behaviour:

Upvotes: 0

Views: 73

Answers (0)

Related Questions