12-31-2012 07:28 AM
I have many text fields in my app that recalculate when editted. The issue is I only want them to recalculate when the user edits the number and not when the app inserts a result into them. I'm using onTextChanged to fire my calculation function which works great if I could surpress it when the code itself changes the value. It's driving me mad! Please help!
Solved! Go to Solution.
12-31-2012 07:53 AM
I've been experimenting with focus this morning figuring that when the user edits text the field will have focus and that will be the difference. It does have focus during textChanging but not during textChanged. I have found a property I can set so the field won't lose focus but am not sure how to use it. The property is focusRetentionPolicyFlags. I tried
focusRetentionPolicyFlags: LoseToFocusable but that doesn't work.
12-31-2012 08:33 AM - edited 12-31-2012 08:36 AM
In QML just disconnect the signal then connect it again. Example:
12-31-2012 09:50 AM
Thanks for the help but I used a different technic that seems to work great in it's simplicity. I simply use onfocuschanged method. In the method I check for loss of focus (as opposed to gaining focus) and do my calculations then. This way when the user changes the value and either clicks done or otherwise dismisses the keyboard the calculation fires but when the code alters the value no focus is gained or lost and therefore doesn't fire the calculation.
12-31-2012 12:13 PM
12-31-2012 03:48 PM
Funny you mention that because that is the system I used in my android code but it seemed to fail when ported over. I blamed it on multiple threads but not sure exactly why it didn't work.
12-31-2012 04:06 PM