Recent

Author Topic: Let's avoid the mistakes of Delphi  (Read 13114 times)

DelphiUser

  • Guest
Let's avoid the mistakes of Delphi
« on: February 03, 2004, 03:01:56 pm »
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

  • Jr. Member
  • **
  • Posts: 86
Let's avoid the mistakes of Delphi
« Reply #1 on: February 03, 2004, 10:58:46 pm »
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

  • Administrator
  • Hero Member
  • *
  • Posts: 2649
Re: Let's avoid the mistakes of Delphi
« Reply #2 on: February 03, 2004, 11:04:36 pm »
Quote from: "DelphiUser"

Why do the components <CheckBox,Listbox,ComboBox> not have an OnChange event ?

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.


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.


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.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Anonymous

  • Guest
Let's avoid the mistakes of Delphi
« Reply #3 on: February 04, 2004, 08:50:03 am »
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

  • Administrator
  • Hero Member
  • *
  • Posts: 2649
Let's avoid the mistakes of Delphi
« Reply #4 on: February 04, 2004, 11:42:26 am »
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 :)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Anonymous

  • Guest
Let's avoid the mistakes of Delphi
« Reply #5 on: February 04, 2004, 01:26:56 pm »
Moving an item from one listbox to another by drag and drop is for sure an user action.
If you are interested I will send you my delphi component so you can see what I mean.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2649
Let's avoid the mistakes of Delphi
« Reply #6 on: February 04, 2004, 05:17:29 pm »
I do know what yo mean, however to put items from one list to another, you have to code that yourself in the drop event. And because of that, you dont need an extra event, since you know you are modifying the lists.
If there would be a list which supports adding items by drag&drop native, then yes, you need an event (maybe)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

 

TinyPortal © 2005-2018