- Home /
Keep keyboard open when lost focus by clicking background canvas - TextMeshPro Input Field
I have a form that contains a few input fields. I want to scroll down the UI while the keyboard is open. UI has a canvas and it's scrollable. But when I touch the canvas while the keyboard open, the keyboard will close due to lost focus. I found a few related questions but can't achieve this. If anyone knows how to achieve this behaviour, please help me.
I'm using TextMeshPro input fields
Platform - Android and iOS. @alnovlucky
Answer by Llama_w_2Ls · Dec 13, 2020 at 05:25 PM
I believe you can manually set the focus of UI elements in Unity by using an eventsystem. This used to be easier in WinForms (C# Windows application tools) where you can use the method GetFocus()
, however in Unity, this is done by, I believe, EventSystem.current.SetSelectedGameObject(yourGameobject);
or UIElement.Select()
When you touch the canvas, set the focus back to the inputField, is what I was trying to say. @VenoliS
@Llama_w_2Ls Thank you for replying! I have already tried that. When I did that, the keyboard is also gone and visible again. This is ugly and not I wanted coz when this happens I can't scroll the canvas anyway. Please let me know if u know any other way to handle this.
I'm pretty sure that there is no way to have focus on two UI elements. Instead, you might need a workaround for scrolling your canvas, like a gameObject instead, that moves dependant on mouse position. @VenoliS
Your answer
Follow this Question
Related Questions
Using the IOS Keyboard 2 Answers
Don't show the mobile keyboard 1 Answer
Mobile Keyboard event calls 2 Answers
How to make floating mobile keyboard in mobile game ? 0 Answers
iOS keyboard - adding and removing characters in a string on the fly 0 Answers