I want to keep the initial list item when the user cancels the selection with ESCAPE.What do you mean with "initial list item"? The Combobox.ItemIndex? It does not change when you press ESCAPE and query it in the OnChange event.
the OnChange event is fired even when the user choose the same value. It looks like a bug, because if the user choose the same value, it means that nothing changed and the OnChange must not be fired. AFAIR earlier the TComboBox class worked different.The attached demo lists the events related to combobox selection in a memo. I ran it back to Laz 1.0, and even this old version shows the same behavior as Lazarus trunk today: The OnChange event is fired even when the already selected item is selected again. A bug? I don't know, the LCL and VLC are full of these inconsistencies, many of them had to be swallowed to keep Delphi compatibility.
I ran it back to Laz 1.0, and even this old version shows the same behavior as Lazarus trunk today: The OnChange event is fired even when the already selected item is selected again.
A bug?
ComboBox1EditingDone, ItemIndex: -1 //Open by click
ComboBox1EditingDone, ItemIndex: -1 //Close, Click inside combobox
ComboBox1EditingDone, ItemIndex: -1 //Open Alt+Down
ComboBox1EditingDone, ItemIndex: -1 //Close by Esc
ComboBox1EditingDone, ItemIndex: -1 //Open by click
ComboBox1Change, ItemIndex: 0 //Selecting first Item On The List
ComboBox1Select, ItemIndex: 0 //Selecting first Item On The List
ComboBox1EditingDone, ItemIndex: 0 //Close, Selecting first Item On The List
ComboBox1EditingDone, ItemIndex: 0 //Open
ComboBox1EditingDone, ItemIndex: 0 //Close, Click selected item again(no onChange/onSelect fired)
ComboBox1EditingDone, ItemIndex: 0 //Opne
ComboBox1EditingDone, ItemIndex: 0 //Pick Selected item with arrow keys and hit Enter (no onChange/onSelect fired)
ComboBox1EditingDone, ItemIndex: 0 //Open
ComboBox1Change, ItemIndex: 1 //Select second Item
ComboBox1Select, ItemIndex: 1 //Select second Item
ComboBox1EditingDone, ItemIndex: 1 //Close Select second Item
ComboBox1Change, ItemIndex: -1 //Start typing(Something not on the list, No what you type, even exist item, ItemIndex will be -1)
ComboBox1Change, ItemIndex: -1 //Fires on every key(char),insertin or removing(BackSpc/Del)
ComboBox1Change, ItemIndex: -1
ComboBox1Change, ItemIndex: -1
ComboBox1Change, ItemIndex: -1
ComboBox1Change, ItemIndex: -1
ComboBox1EditingDone, ItemIndex: -1 //Lost focus
I can't see what you guys say.
What do you mean with "initial list item"? The Combobox.ItemIndex? It does not change when you press ESCAPE and query it in the OnChange event.
if you are in a jam you can do this..