TEdit.OnChange event handler is calling twice for same text
Original Reporter info from Mantis: accorp @accorp
-
Reporter name:
Original Reporter info from Mantis: accorp @accorp
- Reporter name:
Description:
If edit text is modified inside OnChange handler:
procedure TForm1.Edit1Change(Sender: TObject); begin Edit1.Text:='from-on-change'; end;
then executing
Edit1.Text:='test';
trigger OnChange event one time for 'test' and twice for 'from-on-change'.
Additional information:
Method TWinControl.RealSetText is calling TControl.RealSetText with old value, while text was already updated.
procedure TWinControl.RealSetText(const AValue: TCaption); // AValue = 'test' begin ... WSSetText(AValue); // call OnChange, set text to 'from-on-change' ... inherited RealSetText(AValue); // text was modified, but AValue = 'test' ... end; procedure TControl.RealSetText(const Value: TCaption); begin if RealGetText = Value then Exit; // 'from-on-change' &LtPos;> 'test' FCaption := Value; Perform(CM_TEXTCHANGED, 0, 0); // extra OnChange end;
Mantis conversion info:
- Mantis ID: 32602
- OS: Xubuntu 16.04
- Build: r56166
- Version: 1.9 (SVN)
- Monitored by: » a.ramos (a.ramos), » @onpok (Ondrej Pokorny), » @flyingsheep (Bart Broersma)