I have a list of components for my Inno Setup installer, 19 different options, I want to set the OnClick
event for ONE of the components. Is there a way to do this? Or is there a way to check which component triggered the OnClick
event if it's set for all components?
Currently, the OnClick
event is set like so:
Wizardform.ComponentsList.OnClick := @CheckChange;
I would like to do something like:
Wizardform.ComponentsList.Items[x].OnClick := @DbCheckChange;
The WizardForm.ComponentList
is declared as a: TNewCheckListBox
Most component events have a
Sender
parameter to point at the component object that is firing the event. However, in this case, theSender
will likely be theComponentsList
itself. Depending on whatComponentsList
is actually declared as (TListBox
, etc), it may have a property to specify which item is currently being selected/clicked (ItemIndex
, etc). Or it might even have a separate event to report per-item clicks. You did not say whatComponentsList
is declared as, so nobody here can tell you exactly what to look for in it.You do not want to use
OnClick
, useOnClickChange
instead.The
OnClick
is called for clicks which do not change checked state (like clicks outside of any item; or clicks on fixed items; or selection change using keyboard), but mainly it is not called for checks using keyboard.The
OnClickChange
is called only, when the checked state changes, and both for keyboard and mouse.To tell which item was checked by user, use
ItemIndex
property. The user can check only the selected item.Though if you have a components hierarchy, or setup types, the items checked automatically by the installer due to a change in child/parent items or change in the setup type, won't trigger the
OnClickCheck
(nor theOnClick
). So to tell all changes, all you can do is to remember the previous state and compare it against the current state, when theWizardForm.ComponentsList.OnClickCheck
orWizardForm.TypesCombo.OnChange
are called.For a more generic solution, see Inno Setup Detect changed task/item in TasksList.OnClickCheck event. Though with components, one has to trigger the check on the
WizardForm.TypesCombo.OnChange
call too.