Archive: Managing dependent sections


Managing dependent sections
  Hello all,

I am looking for a way to manage multiple dependent sections. Basically I have a set of sections similar to this:


SectionGroup

Section"Primary Section" ps
SectionEnd
Section"Dependent Section 1" ds1
SectionEnd
Section"Dependent Section 2" ds2
SectionEnd
Section"Dependent Section 3" ds3
SectionEnd
Section"Dependent Section 4" ds4
SectionEnd
SectionGroupEnd
>
I need to ensure that if any of the dependent sections are selected the primary section is also selected, also I need to ensure that if the primary section is unselected then all dependents are unselected.

I have been playing around with .onSelChange and the code found at:

http://nsis.sourceforge.net/Section_Dependency

However, I am too thick to get this working

Try this code:


!include "LogicLib.nsh"
...
${If} ${SectionIsSelected} ds1
${OrIf} ${SectionIsSelected} ds2
${OrIf} ${SectionIsSelected} ds3
${OrIf} ${SectionIsSelected} ds4
!insertmacro SelectSection ps
${EndIf}
${Unless} ${SectionIsSelected} ps
!insertmacro UnselectSection ds1
!insertmacro UnselectSection ds2
!insertmacro UnselectSection ds3
!insertmacro UnselectSection ds4
${EndUnless}
...

Thanks for the reply, unfortunately I could not get it to work either. However, your use of LogicLib got me thinking and I came up with an alternative solution.

Basically, if a user deselects the primary section all dependent sections are unchecked and disabled. If the user then reselects the primary section they now have the option of choosing which dependant sections they want.


!DEFINE SF_DISABLED 16
!DEFINE SF_ENABLED_UNCHECKED 0

Function .onSelChange
SectionGetFlags ${ps} $0
SectionGetFlags ${ds1} $1

${If} $0 != ${SF_SELECTED}
SectionSetFlags ${ds1} ${SF_DISABLED}
SectionSetFlags ${ds2} ${SF_DISABLED}
SectionSetFlags ${ds3} ${SF_DISABLED}
SectionSetFlags ${ds4} ${SF_DISABLED}
${ElseIf} $1 == ${SF_DISABLED}
SectionSetFlags ${ds1} ${SF_ENABLED_UNCHECKED}
SectionSetFlags ${ds2} ${SF_ENABLED_UNCHECKED}
SectionSetFlags ${ds3} ${SF_ENABLED_UNCHECKED}
SectionSetFlags ${ds4} ${SF_ENABLED_UNCHECKED}
${EndIf}
FunctionEnd


While this works, I would still be curious to find out if there is a way of doing it as I originally planned

:p
Small typo - forget ${} for all section id, i.e. ${ps}, ${ds1}.

While this works, I would still be curious to find out if there is a way of doing it as I originally planned
Why this code does not work as you planned?