sqlchild
sqlchild

Reputation: 9074

hide section in nsis installer conditionally on choice of radiobuttons

How can a section be hidden conditionally on check or uncheck of RadioButtons in MUI NSIS installer Components Page dialog.

I have added 2 RadioButtons, DEMO & BACKUP.

When user chooses, DEMO RadioButton , then Section displayed will be "INSTALL DATA OR NOT", it can be checked or unchecked by the user, & "BACKUP DATA OR NOT" section would be hidden.

When user chooses, BACKUP RadioButton , then Section displayed will be "BACKUP DATA OR NOT", it can be checked or unchecked by the user, & "INSTALL DATA OR NOT" section would be hidden.

IF I USE THE - SIGN, then the section "INSTALL DATA OR NOT" is hidden for BOTH RADIOBUTTON CHOICES, i.e. for DEMO also & for UPDATE also, please help.

Also , there are features of SelectSection or UnSelectSection, but they do not hide the Section, which is what I want, that the Section should be hidden and unchecked.

Upvotes: 4

Views: 5523

Answers (1)

Anders
Anders

Reputation: 101666

A hidden section has no name so you need to give it a name for it to become visible again:

!include Logiclib.nsh
!include Sections.nsh

page Components InitComponentsPage

!define INSTALLSECTIONNAME "Install"
section "" SEC_INSTALL
sectionend

!define BACKUPSECTIONNAME "Backup"
section "" SEC_BACKUP
sectionend

Function InitComponentsPage
${If} $InstallType == BACKUP
    SectionSetText ${SEC_BACKUP} "${BACKUPSECTIONNAME}"
    !insertmacro UnSelectSection ${SEC_INSTALL}
    SectionSetText ${SEC_INSTALL} ""
${Else}
    SectionSetText ${SEC_INSTALL} "${INSTALLSECTIONNAME}"
    !insertmacro UnSelectSection ${SEC_BACKUP}
    SectionSetText ${SEC_BACKUP} ""
${EndIf}
Functionend

Upvotes: 7

Related Questions