; one-section.nsi
;
; This example demonstrates how to control section selection.
; It allows only one of the sections of a group to be selected.

;--------------------------------

; Section define/macro header file
; See this header file for more info

!include "Sections.nsh"

;--------------------------------

Name "One Section"
OutFile "one-section.exe"

;--------------------------------

; Pages

Page components

;--------------------------------

; Sections

Section /o "aaaa" g0o0

SectionEnd

SubSection "bbbb" ss1

Section "Group 1 - Option 1" g1o1
SectionEnd

Section "Group 1 - Option 2" g1o2
SectionEnd

SubSectionEnd

;--------------------------------

; Functions

; $1 stores the status of group 1

Function .onInit
  StrCpy $1 ${ss1}
FunctionEnd

Function .onSelChange
  StrCmp $1 ${ss1} last_subsec
  StrCmp $1 ${g0o0} last_sec
  Goto end

last_subsec:
  !insertmacro SectionFlagIsSet ${g0o0} ${SF_SELECTED} "" end
    !insertmacro UnselectSection ${g1o1}
    !insertmacro UnselectSection ${g1o2}
    StrCpy $1 ${g0o0}
    Goto end

last_sec:
  !insertmacro SectionFlagIsSet ${ss1} ${SF_SELECTED} unselectSec ""
  !insertmacro SectionFlagIsSet ${ss1} ${SF_PSELECTED} unselectSec end
  unselectSec:
    !insertmacro UnselectSection ${g0o0}
    StrCpy $1 ${ss1}
    Goto end

end:
FunctionEnd