Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strange (unexpected) OnAsyncExit behavior
Hi All,

I'm experiencing a strange (read: unexpected) behavior using an IWEdits OnAsyncExit procedure, and it easy to recreate in a really simple test:

Create a simple form with two IWdit components, IWEdit1 and IWEdit2, having taborder 0 and 1. 
Use the FormShow event to IWEdit1.SetFocus.
Add the following line to the IWEdit1.OnAsyncExit event:

If IWEdit1.Text = 'AA' then IWEdit2.Text := 'BB';

Run the program and press tab when IWEdit1 has focus. The Text property of IWEdit2 is correctly selected.
Now, jump back to IWEdit1 and enter AA and press tab again.
Correctly the contents of IWEdit2.Text is set to BB, BUT instead of having BB as a selected text, it is not selected and the cursor is placed after the text.
Again, jump back to IWEdit1, still containing AA, and press TAB again.
Now IWEdit2 still has BB as contents, but it is selected as it should be.

It is ONLY wrong, when the contents of the text is changed AND the focus is shifted to the component at the same time.

Anybody know why and how I can avoid this ?

Further test: if I add another IWEdit (or other tababel component) in between IWEdit1 and IWEdit2,changing the tab order accordingly, the problem goes away and everything is as expected.

So: the problem is only when the contents of the IwEdit component being jumped to, is changed by the onasyncexit procedure of the Iwedit being jumped from. I suspect it has something to do with the order in which the events, OnExit, OnChange and OnEnter, is handled, but I admit I'm only guessing.

NB! I'm still on 10.3.2 with updates and 15.1.17.
Do you have a ready to run test case? It would make things easier to investigate....
Hi Alexandre,

Thanks for your reply. I have tried to attach a zipfile with all files in the simple project, but it was rejected with a message telling me only 1024K size is allowed.

So, instead I only attach a zip file with the Unit1 files. Create a new, standalone, project, with standard settings, and replace the Unit1 files with the attached and run it from the IDE. You'll see the behavior right away.

And for further testing purpose, add a 3rd iWEdit, and give it tab order 1 and note the difference.


Attached Files
.zip (Size: 937 bytes / Downloads: 2)
Thanks. I'll have a look and get back to you
Hi Soren,

I've just committed a fix in our main IW branch. It should be available in the next release, probably this weekend.

Hi Alexandre,

Thanks for the reply. I'll look forward to it.


Forum Jump:

Users browsing this thread: 1 Guest(s)