简体   繁体   English

根据选择的单选按钮有条件地隐藏 nsis 安装程序中的部分

[英]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.如何在 MUI NSIS 安装程序组件页面对话框中选中或取消选中 RadioButtons 时有条件地隐藏部分。

I have added 2 RadioButtons, DEMO & BACKUP.我添加了 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.当用户选择 DEMO RadioButton 时,显示的部分将是“安装数据或不”,用户可以选中或取消选中,“备份数据或不”部分将被隐藏。

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.当用户选择 BACKUP RadioButton 时,显示的部分将是“BACKUP DATA OR NOT”,用户可以选中或取消选中,&“INSTALL DATA OR NOT”部分将被隐藏。

IF I USE THE - SIGN, then the section "INSTALL DATA OR NOT" is hidden for BOTH RADIOBUTTON CHOICES, ie for DEMO also & for UPDATE also, please help.如果我使用 - 符号,则“是否安装数据”部分对于 BOTH RADIOBUTTON CHOICES,即 DEMO 和 UPDATE 也是隐藏的,请帮助。

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.此外,还有 SelectSection 或 UnSelectSection 的功能,但它们不会隐藏 Section,这正是我想要的,即 Section 应该被隐藏和取消选中。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM