I can't seem to find a way to prevent a text edit field from losing keyboard focus when another widget is clicked--I hope I'm just overlooking the solution.
Here is the situation:
Suppose that there are two text edit widgets (TE1 and TE2) on a dialog box.
The current behavior:
1. User enters some text in TE1.
2. User clicks in the TE2 field.
3. TE1's update handler code handles the kEditBoxGiveUpKeyFocusMessage that was triggered when TE2 was clicked.
4. The handler, notices that TE1 contains an invalid text value.
5. The handler displays a warning stating the problem.
6. TE2 gets the keyboard focus because it was clicked.
The desired behavior is to have Step 6 change to:
6. [DESIRED] Due to its bad data, TE1 keeps the keyboard focus (the click on TE2 is ignored).
Thanks in advance for any help!!
Try to implement "ITextDataValidation" for the Edit box instead of using event handler to check invalid values.
As and when TE1 looses key focus (TE2 is clicked), the TextDataValidation will check for the validity of value & alert will come up. Once you close the warning alert, focus will remain in TE1.
Hope this helps you.