Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strange problem: Sync/Async issue ?
Hi Guys,

I have a strange problems I hope you can help me with. I'm might be looking in the wrong place, but so far I have not been able to pinpoint the actual reason for the behavior:

I have a simple form with 3 IWEdit fields and a button. All three are standard text (not using any of the new options yet), Field 1 has an OnExit event, and field 1 to 3 has one (sharing the same) OnAsyncKeyDown event. NB! In the OnAsyncKeyDown, I check if EventParams['which'] is '9' in which case I exit the event right away. If not, I set the background color of the fields 2 and 3 to ClWebWhite. Taborder is one-two-three downwards.

Field 1: Item number: Onexit event: Check table for item. If item found present name and price in the fields. If not found, show empty fields.
Field 2: Item name
Field 3: Price

Button 1: Check contents of fields: if Ok, try to save (Insert or Update) Item. If not ok, report an error and set background color of the erroneous field to clWebYellow.

AND I have JavaScript on the form looking for certain Keykombinations. If F10, do the same as clicking the button with the mouse. It works pretty well.

Simple in a way, yet with problems: 

When I tab though the fields, clicking the button with the mouse everything is working as expected. Errors are reported with a WebYellow color and next keydown, typically in the same field, resets the color to WebWhite.

When pressing F10 on the other hand, everything is being tested as if I clicked the button with the mouse, and if an error, the erroneous field is turned WebYellow. This time however, the keydown event, setting the color to WebWhite, is no longer working. Test shows the event is being handled and it is setting the background color of the field to webwhite, but regardless, the Yellow color stays. It's being told to change from Yellow to white, and act as if it do, but refuses to comply. When leaving the form and returning everything is again working as expected, until I press F10.....

How can I be, that the program is able to set the color to yellow, in the Async state, and to reset it to White, still in the Async state, and as soon as I use the F10, it can set the color to Yellow, but other events cannot change color back to white. Both the Mouse Click on the Button and the F10 makes a round trip to the server to try to save the contents, but it is as if the program looses it's ability to commit actual changes to colors in the async events, after the F10.

NB! If I deliberately perform an OnClick event after return form the F10 event, it appears to work again, so something tells me it an Sync/Async issue but I can't seem to put my finger on where or what. I hope some of you have had similar problems and have found a workaound, or workable solution.


After post edit: I forgot to mention I'm using Delphi 10.3.2 with upgrades and IW 15.1.12

Forum Jump:

Users browsing this thread: 1 Guest(s)