[Lazarus] Order of events: TEdit / TListBox

kapibara kapibara.pas at aol.com
Mon May 22 23:39:45 CEST 2017


Is this a bug?

Simple demo: TEdit and TListBox are on a form. The TEdit is used to 
rename selected string in the ListBox. The code for renaming is in the 
Exit event of the TEdit. When an item in the ListBox is selected, the 
Edit.Exit should fire and copy the Edit.Text to the current item in the 
ListBox. The OnSelectionChange then copies the name of the selected 
ListBox item to the TEdit.

This only works if selecting the already selected item in the ListBox. 
If instead another Item is selected, the Edit.Text is overwritten before 
it is copied to the old ListBox item: the ListBox.OnSelectionChange 
fires before Edit.Exit.

ListBox.OnSelectionChange fires *before* both ListBox.Click and 
Edit.Exit. I would expect Click to fire before SelectionChange? And 
Edit.Exit before ListBox.Click, which it does, but only if 
OnSelectionChange doesn't fire at all.

Clicking an item in the ListBox that is already selected results in the 
same event order as in Delphi: Edit.Exit -> ListBox.Click.

Lazarus trunk, GTK2 Linux

There is an attached project.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: OrderOfEvents.zip
Type: application/zip
Size: 2458 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170522/b99f9f96/attachment.zip>


More information about the Lazarus mailing list