Hmm.. I took a look at the wiki article (
http://nsis.sourceforge.net/Section_Dependency ) and made a LogicLib version below.
There are some differences, however.. From reading the wiki, there's a comment that reads "# Check if Sec2 was just selected then select Sec3 and Sec4.". However, it doesn't actually do that in the code there. The below LogicLib'd code does.
In short, the behavior is as follows:
Selecting Section 2 -> Selects Section 3 and Section 4
Unselecting Section 2 -> Unselects Section 3 and Section 4
Selecting Section 3 -> Selects Section 2
Selecting Section 4 -> Selects Section 2
To match the behavior of the wiki article code, just remove the code that selects Section 3 and Section 4 when Section 2 was selected.
In addition, I have hardcoded the value of the independent section's selected state in .onInit. The reason I've hardcoded this is because, presumably, as the author of the installer you would -know- whether your independent section ('Section 2' in the example) is selected on startup or not (made optional using "Section /o"), so detecting this at runtime is a bit wasteful.
Name SectionDependencyLogicLib
OutFile SectionDependencyLogicLib.exe
Var IndependentSectionState
Page Components
!include Sections.nsh
; LogicLib and some additional defines for convenience
!include LogicLib.nsh
!define SelectSection `!insertmacro SelectSection`
!define UnselectSection `!insertmacro UnselectSection`
Section "Section 1" Sec1
SectionIn RO
SectionEnd
Section "Section 2" Sec2
SectionEnd
Section /o "Section 3" Sec3
SectionEnd
Section /o "Section 4" Sec4
SectionEnd
Function .onInit
StrCpy $IndependentSectionState 1
FunctionEnd
Function .onSelChange
${If} ${SectionIsSelected} ${Sec2}
${If} $IndependentSectionState != 1
StrCpy $IndependentSectionState 1
${SelectSection} ${Sec3}
${SelectSection} ${Sec4}
${EndIf}
${Else}
${If} $IndependentSectionState != 0
StrCpy $IndependentSectionState 0
${UnselectSection} ${Sec3}
${UnselectSection} ${Sec4}
${EndIf}
${EndIf}
${If} ${SectionIsSelected} ${Sec3}
${OrIf} ${SectionIsSelected} ${Sec4}
StrCpy $IndependentSectionState 1
${SelectSection} ${Sec2}
${EndIf}
FunctionEnd