Archive: Component dependencies and checkboxes


Component dependencies and checkboxes
How can I make the checked state of checkboxes in the MUI2 COMPONENTS page depend on the state of other checkboxes in the tree, to reflect dependencies between components being installed.

For example: Say I have a SectionGroup called "Options" which contains Sections called "Option Manager", "Option 1" and "Option 2". The entire group is optional, but if the user selects either "Option 1" or "Option 2" then "Option Manager" will also be selected, and if the user deselects "Option Manager" then both "Option 1" and "Option 2" must also be deselected (greyed would be good, too, but by no means essential).

Note that it is valid to install "Option Manager" without either "Option 1" or "Option 2" (because there are other possible options that are not part of the standard install).

I currently have "Option Manager" as a hidden section, which means that if the user selects the "Options" section it will be selected and if he deselects "Options" then it will be deselected. The trouble with this is that it isn't obvious to the user that the manager component exists. The users find it confusing that they have to select "Options" and then deselect "Option 1" and "Option 2" to get just the manager.

It would be sufficient to show "Option Manager" as a component that was always selected if the SectionGroup was selected (something like SectionIn, but depending on the selection state of the parent SectionGroup, rather than on an InstType). Can that be done? It's not exactly what I'd like but at least it would be clear to the users.


Name "Test"
OutFile "Test.exe"

Page components
Page instfiles

!include "Sections.nsh"
!include "logiclib.nsh"

SectionGroup /e "Options"
Section /o "Option Manager" sec1
#
SectionEnd

Section /o "Option 1" sec2
#
SectionEnd

Section /o "Option 2" sec3
#
SectionEnd
SectionGroupEnd

Function .onSelChange
SectionGetFlags ${sec1} $R1
IntOp $R1 $R1 & ${SF_SELECTED}

SectionGetFlags ${sec2} $R2
IntOp $R2 $R2 & ${SF_SELECTED}

SectionGetFlags ${sec3} $R3
IntOp $R3 $R3 & ${SF_SELECTED}

${If} $R2 = ${SF_SELECTED}
${OrIf} $R3 = ${SF_SELECTED}
!insertmacro SelectSection ${sec1}
!insertmacro SetSectionFlag ${sec1} ${SF_RO}
${Else}
${If} $R2 != ${SF_SELECTED}
${AndIf} $R3 != ${SF_SELECTED}
!insertmacro ClearSectionFlag ${sec1} ${SF_RO}
${EndIf}
${EndIf}
FunctionEnd

Thank you
Neat, thanks. That works nicely ... now I just have to work out how! :)


Yes, but ...

Originally posted by Daniel James
Neat, thanks. That works nicely ... now I just have to work out how!
... and, more particularly, whether the same thing can be done with the checkboxes on a page created by
!insertmacro MUI_PAGE_COMPONENTS


Any clues?

Worked it out ...

Originally posted by Daniel James
... and, more particularly, whether the same thing can be done with the checkboxes on a page created by
!insertmacro MUI_PAGE_COMPONENTS
It's OK, I've worked it out for myself. The .onSelChange function has to be after the definitions of the sections in the .nsi file (even though the MUI_PAGE_COMPONENTS macro doesn't have to be). :weird:

Thanks again, Red Wine.

You might find....
... my thread on Section dependencies useful (http://forums.winamp.com/showthread....hreadid=272007)