I need to bind OnAsyncChange on TIWDBEdit to trigger to field change to calculate some field then reflect changes to user, and I use a TIWButton.OnAsyncClick to Post the DataSet changes.
To use the sample project attached.
Sample.zip (Size: 8.04 KB / Downloads: 0)
1) Click Edit.
2) When in edit state, focus on the TIWDBEdit and try to change the code
3) Do not click other place so TIWDBEdit does not lose focus and trigger OnAsyncChange.
4) Click on Post button directly. (this will trigger TIWDBEdit.OnAsyncChange then TIWButton.OnAsyncClick)
I notice a different behavior between Mouse Click Device (Desktop) and Touch Device (Phone). When I use browser inspect tool, I can see the timing like this.
First Img: Mouse Click Device.png
First callback is OnAsyncChange and second callback is OnAsyncClick, it can be seen that they are far away and do not overlap
Second Img: Touch Device.png
It can be seen that OnAsyncChange overlapped with OnAsyncClick callback.
There are rare cases that will happen sometimes, like this image, OnAsyncClick finished faster than OnAsyncChange. This cause
to be runned first and EventParams does not contain EDCODE=NewValue, so its posted without change in value
based on IWBase.js, when typing on edCode, it is added to window.ChangedControls, but bcz SendPostRequest of OnAsyncChange cleared the window.ChangedControls, SendPostRequest of OnAsyncClick cannot see edCode as changed and cannot pass the changed value to server
=========================================================================
if u uncomment the Exception in field change, you can see when you redo the above step
For Mouse click device, due to its no overlapping behavior, when OnFieldChange raise the Exception, OnAsyncClick callback is not run at all (the value on the field is reverted and posting is not done, this is the more correct behavior)
For Touch device, when OnFieldChange raise the Exception, OnAsyncClick callback is still runned (the value on the field is reverted and posted directly).
==============================================================================
This is probably not a bug, but rather a issue due to touch and click difference, any idea to solve this?
To use the sample project attached.
![ZIP File .zip](https://www.atozed.com/forums/images/attachtypes/zip.png)
1) Click Edit.
2) When in edit state, focus on the TIWDBEdit and try to change the code
3) Do not click other place so TIWDBEdit does not lose focus and trigger OnAsyncChange.
4) Click on Post button directly. (this will trigger TIWDBEdit.OnAsyncChange then TIWButton.OnAsyncClick)
I notice a different behavior between Mouse Click Device (Desktop) and Touch Device (Phone). When I use browser inspect tool, I can see the timing like this.
First Img: Mouse Click Device.png
First callback is OnAsyncChange and second callback is OnAsyncClick, it can be seen that they are far away and do not overlap
Second Img: Touch Device.png
It can be seen that OnAsyncChange overlapped with OnAsyncClick callback.
There are rare cases that will happen sometimes, like this image, OnAsyncClick finished faster than OnAsyncChange. This cause
Code:
procedure TIWForm1.btnPostAsyncClick(Sender: TObject; EventParams: TStringList);
to be runned first and EventParams does not contain EDCODE=NewValue, so its posted without change in value
based on IWBase.js, when typing on edCode, it is added to window.ChangedControls, but bcz SendPostRequest of OnAsyncChange cleared the window.ChangedControls, SendPostRequest of OnAsyncClick cannot see edCode as changed and cannot pass the changed value to server
=========================================================================
if u uncomment the Exception in field change, you can see when you redo the above step
For Mouse click device, due to its no overlapping behavior, when OnFieldChange raise the Exception, OnAsyncClick callback is not run at all (the value on the field is reverted and posting is not done, this is the more correct behavior)
For Touch device, when OnFieldChange raise the Exception, OnAsyncClick callback is still runned (the value on the field is reverted and posted directly).
==============================================================================
This is probably not a bug, but rather a issue due to touch and click difference, any idea to solve this?