Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tricky OnExit and SetFocus problem.
#1
Hi All,

I have a very tricky problem I'm unsure how to solve.

I have two IWEdits, IwEdit1 and IWdit2. Each has an OnExit event. The events are similar:

in IwEdit1.onExit: if IwEdit1.text = '' then IwEdit1.SetFocus; and
in IwEdit2.onExit: if IwEdit2.text = '' then IwEdit2.SetFocus;.

IWEdit2 is next logical field after IWEdit1 in the Taborder, and when both IwEdits are empty, and I tab out of IWEdit1, then the cursor starts an endless jump between the two IwEdits, because:

When exiting IwEdit1, the cursor is first moved to IwEdit2. Then the code realizes IwEdit1 is empty, and Setfocus moves it back to IwEdit1. However, as the Cursor already was in IwEdit2, IwEdit2.OnExit realizes the Cursor has left, and as IwEdit2 is empty, IwEdit2's SetFocus, moves it back to IwEdit2. And so IwEdit1.OnExit takes over again and so on and on and on....

How can I break this ?

In VCL, in Edit1.OnExit, I would disable Edit2's OnExit event before executing Edit1.Setfocus, and enable it again after, so that when Edit1.Setfocus pulls it out of Edit2, Edit2's OnExit event is not fired. How can I do something similar in InterWeb with IwEdits ?

Regards
Soren
Reply


Messages In This Thread
Tricky OnExit and SetFocus problem. - by SorenJensen - 01-29-2020, 04:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)