I have an iOS project in Xojo 2024r3.1 with a MobileScrollableArea which has a container. The container has fields and text area at the bottom. When I scroll down and tap inside the textarea does not animate above the keyboard and I can’t see or type in it.
I have 3 screens with scrollable areas, 1 modal and 2 normal and they all do this.
If I add code to move the scroll of the scrollablearea on FocusReceived, it works, but I think I need to reset the scroll because the other fields are affected? When I try resetting the scroll in FocusLost, the app crashes.
What should happen if the textarea is taller than the visible space when the keyboard is visible?
IIRC, the logic was to calculate the bottom on the text in the text area and only scroll things upwards if the bottom would be under the keyboard, but it doesn’t recalculate while you type.
The scroll view adds a whole other dimension to the problem in that the framework can’t just scroll that for you. Your best bet will be to have or add a constraint that moves these things for you.
The textareas in my app are height 200. They seem to scroll correctly within the scrollablearea when typing, so that doesn’t seem to be an issue.
For the time being, I have added extra height to the container, to add blank space at the bottom, and that lets the textarea scroll into view above the keyboard.
Not sure what constraints I should add, do you have any suggestions that I can look into?
well if you’re adding a blank area at the bottom, I’d say that instead you could just add the constraint when the field gets focus and then remove it when it loses focus. That means that you need to keep the constraint around which lends itself to subclassing the control…
This is an example of creating a textarea that creates a new top constraint and activates it when it gets focus and then deactivates the constraint and destroys it when it loses focus.
One thing that’s important to note in this project is what I’ve done to the original vertical constraint. The Top constraint that was set in the IDE had its priority changed from Highest to High. That’s so that when the new constraint is added, it will override the behavior of the one from the IDE.
If you’re interested in getting a better understanding of how constraints work I did a Xojo hosted one of my webinars last year and I made a set of classes to give users more control over how they work.