Skip to content
GitLab
Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • Lazarus Lazarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 2,104
    • Issues 2,104
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • LazarusLazarus
  • LazarusLazarus
  • Issues
  • #32602
Closed
Open
Issue created Oct 23, 2017 by FPC Admin account@fpc_adminOwner

TEdit.OnChange event handler is calling twice for same text

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)
Assignee
Assign to
Time tracking