TDBDateEdit interferes with other Data Aware Controls
Original Reporter info from Mantis: TWhyman
-
Reporter name: Tony Whyman
Original Reporter info from Mantis: TWhyman
- Reporter name: Tony Whyman
Description:
The problem can be seen on a form which has a TDBDateEdit and (e.g.) a TDBEdit with the same DataSource. The problem occurs when TDBDateEdit.AutoSelect is true.
Double click on the TDBEdit to select all. Now press any key. Instead of the edit box contents being replaced, the key value is appended to the end of the text - and the Date Edit text appears to be selected.
Now repeat again, but with TDBDateEdit.AutoSelect false. When the key is pressed, the edit box text is replaced i.e. the correct behaviour.
The problem appears to be in TDBDateEdit.AutoSelect where we find
if AutoSelect then SelectAll;
i.e. If AutoSelect is true then SelectAll is always called even when the control is not focused whenever a DataChange event occurs. This seems to be the root of the problem. The proposed fix (see patch) is to change this to
if Focused and AutoSelect then SelectAll;
i.e. SelectAll only called if the control is focussed.