@Bart
Yes, you are right. I tested it with Delphi DX 10.1 Berlin. (Why do I not use Delphi? This is free starter version^^).
But this behavior is related with TButton. I tested with following codes.
procedure TForm1.Edit1Exit(Sender: TObject);
begin
ShowMessage(Edit1.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text := 'Text from button 2';
end;
procedure TForm1.Edit2Enter(Sender: TObject);
begin
Edit1.Text := Edit2.Text;
end;
procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
Edit1.Text := node.text;
end;
procedure TForm1.ListView1SelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
begin
if Selected then Edit1.Text := item.Caption;
end;
Followings occur when I press each control while Edit1 is focused.
1. When I press Button2, Edit1.Text is showmessaged, and when I close, there are no change in the Edit1. And if I press Button2 again, the content of Edit1 is changed (this is very natural becuase Edit1Exit is not called).
2. When I enter Edit2, everything goes as expected.
3. When I select any tree node, everything goes as expected.
4. When I select any listview item, Edit1.Text is modified first, and then the modified message is shown (i.e. selected node.text). But, in Delphi, everything goes as expected here too.
My conclusions are :
1. TButton's behavior is a bug both in Delphi and Lazarus.
2. The order in which events occur when a listview item is selected in Lazarus is wrong. This is a bug (or many bugs). There is a logical order of events happening. In our case, the focus must 1) move away from TEdit, 2) Enter TListView, and then 3) listview item is selected. A person cannot enter a new room before leaving current room.
3. Aside from that, TTreeview should use treenode about to lose focus (or selection) as parameter of OnChanging event handler.