[SOLVED] QML - Dynamically swap the visibility/opacity between overlapping Text and TextArea
I want to have a widget in QML which has combination of the following behaviors:
- Multi line edit
- Auto scroll the content as and when I hit newline. (The content on top of the page keeps going up as and when I enter new content at the bottom)
- Have a placeholder text functionality.
As far as I know, only Text and TextField are having placeholder text property and only TextArea is having a multi line edit plus auto scroll. But If there is any such widget with all the combinations then, my question "Dynamically swap the visibility/opacity between overlapping Text and TextArea " would be invalid.
In case there is no such widget (I wonder why), I am thinking to have a rectangle which has both Text and TextArea overlapping and based on the below logic I want to have the visibility/opacity/focus on one of them:
If the Text Area is empty (0 characters), then have the Text in the foreground with focus and with the placeholder text "Enter some text". But as soon as the user starts typing, the Text should lose the focus, opacity and go to background and the TextArea should gain the focus and come to the foreground and start accepting multi line input. Similarly, when TextArea is in the foreground and is empty (0 characters) and when the user click on any other widget outside my Rectangle, the Text should again gain the focus, come to the foreground and display the placeholder again.
I tried to get inspiration from this code "here...":http://stackoverflow.com/questions/15558831/simple-textarea-element-in-qml, but failed miserably, it would be helpful if anyone can help me with a few lines of code or give me some pointers on how to solve this.
If I understood your requirement correctly, it would be easy to add a Text element to TextArea and then animate the opacity of Text element depending upon the conditions.
Thanks for the response. I got a bit lazy to update the post. I found the answer in here "code":http://stackoverflow.com/questions/27088152/qml-dynamically-swap-the-visibility-opacity-between-overlapping-text-and-texta/27088416#comment42684916_27088416