[SOLVED] Problem with disable action areas (TextField, ...)
-
Hello!
I have a little problem using TextFields, TextAreas, ...
Problem: The use of visible: false does not disable / deactive the TextField / TextArea for me. I can still touch into the TextArea, the keyboards opens and I can type in some characters.
Target: Android 4.4.2 & 4.1.2 (arm)
Lib: Qt 5.2
IDE: QtCreator 3.1
DevComp: Windows 7 64---------------- detailed problem explanation below ----------------
Regarding to this documentation: "Item":http://qt-project.org/doc/qt-5/qml-qtquick-item.html#visible-prop:
bq. Setting this property directly affects the visible value of child items.
bq. If this property is set to false, the item will no longer receive mouse events, but will continue to receive key events and will retain the keyboard focus if it has been set.
Question: Is a touch event the same as a mouse event if I use a TextField or TextArea on a mobile device?
If yes, I guess it should not react on a touch with a finger if the TextField / TextArea has the property visible: false.I have a application that uses a loader for each "App" (e.g. Compass, General Settings, ...).
All of them inherits a "GeneralApplication" model with some properties.#GenApp.qml:
@import QtQuick 2.2
import QtQuickControls 1.1Item {
property string placeHolder;
...
}@#SettingsApp.qml:
@import QtQuick 2.2
import QtQuickControls 1.1GenApp {
id: appheight: globalDeviceHeight
width: globalDeviceWidthListModel {
id: lv1ListElement {
name: "Set1"
}
}Component {
id: tg1Row {
spacing: 20Text {
text: name
}TextField {
id: tf
}
}
}ListView {
height: 800
width: 400
model: lv1
delegate: tg1
}
}@If I change from one App to the other one, I am modifiying a "activeApp" property of the current and new App.
Regarding this activeApp value, I will change the opacity of the "GenApp"-Item.I also set the GenApp.visible property to false. This should set the focus and visibility of all child-elements to false. But this is not working for the TextField and TextArea elements.
If the App has been changed / switched, I can still click into the TextArea of the previous app...
How can I solve this problem?
[I had to copy the code from one pc without network connection to the one I am using right now by hand. Application is running fine without any typos]
-
You can make binding from visible to enabled. When visible is set to false, the component (e.g. TextArea) will lose focus, will become untouchable and that is your solution.
-
Thanks for the answer.
The enabled-property works fine now.
For some reason, few days ago, it didnt worked...