Forum > LCL
Let's avoid the mistakes of Delphi
DelphiUser:
Hi,
I am becoming more interested in the Lazarus stuff, since it looks like Delphi does no get improved as fast as I like.
To day I came across a problem, which as confused a lot of people.
Why do the components <CheckBox,Listbox,ComboBox> not have an OnChange event ?
Let's try together to define how this should work.
CheckBox: if the Checked property changes, then an OnChange event shall be fired.
Now with ListBox and Combox we need a some more detailed control.
Actually this components use TStrings which could be made better.
An OnContentChange event shall be fired if :
- an item gets added/deleted/changed.
- the list gets cleared/sorted or loadfromfile is called.
An OnChange event shalle be fired if :
- the ItemIndex changes.
So please think about it and let me know if this would clean up the situation ?
After that I will try to implement it.
neli:
Hi, thanks for your input. Please submit bugs on the "Bug tracking" page if you have specific bugs. That will increase their change of being handled properly.
Micha.
Marc:
--- Quote from: "DelphiUser" ---
Why do the components <CheckBox,Listbox,ComboBox> not have an OnChange event ?
--- End quote ---
Probably since we haven't implenented it yet :)
--- Quote from: "DelphiUser" ---
Let's try together to define how this should work.
CheckBox: if the Checked property changes, then an OnChange event shall be fired.
--- End quote ---
Makes sense, however Delphi uses OnClick for it.
--- Quote from: "DelphiUser" ---
Now with ListBox and Combox we need a some more detailed control.
Actually this components use TStrings which could be made better.
An OnContentChange event shall be fired if :
- an item gets added/deleted/changed.
- the list gets cleared/sorted or loadfromfile is called.
An OnChange event shalle be fired if :
- the ItemIndex changes.
--- End quote ---
OnContentChange makes no sennse to me. Events are fired when a user does something. ContentChanges are made through code, and usually they don't fire events.
OnChange makes more sense.
Anonymous:
Ok, let's make me an example where <OnContentChange> could make sense:
A common situation: Two Listboxes (SourceList,TargetList) and 4 Buttons.
The two listboxes are in releation to each other.
1. One listbox (SourceList) contains all items. The other listbox (TargetList) is empty.
2. Now the user can move Items between the two listboxes by drag&drop or by using one of the buttons.
3. The buttons should get enabled/disabled correctly depending on the amout of items in the two listboxes.
Believe me I have encapusulated this in one Delphi component and it was rellay complicated to do this without the Events <OnChange> and <OnContentChange>.
Marc:
This is still no result of a user actiion and all done by code. It depends on your implementation.
If you have the proper routines, you don't need the events.
Believe me, I've done it several times before :)
Navigation
[0] Message Index
[#] Next page