Old 29th August 2013, 04:49   #1
Junior Member
Join Date: Aug 2013
Posts: 1
Optional Radio Buttons

Hi all,

I'm relatively new to NSIS, so excuse my noobness.

I'm using NSIS 2.46 with MUI2. I am trying to create a components page where the component group is optional, but the items in the group are radio buttons.

The context is that I install some prerequisites for my installation. The user can choose 2 options on how those prerequisites are installed, but they can also choose not to install the prerequisites at all.

Currently my code looks something like:



SectionGroup "Prerequisite Installation"
Section "Install Type 1" installType1
Section "Install Type 2" installType2

Function .onInit
StrCpy $1 ${installType1}

Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton "${installType1}"
!insertmacro RadioButton "${installType2}"
!insertmacro EndRadioButtons

Code examples taken from http://stackoverflow.com/questions/1...ams-to-install.

This does give me the "radio button" effect for install types, but I cant deselect the group checkbox (which ok, is "correct" radio button operation. I'm seeing if theres a way to have nothing selected or only 1 selected)

dtm777 is offline   Reply With Quote
Old 7th October 2013, 19:49   #2
Junior Member
Join Date: Apr 2008
Posts: 21
good question, i have the same problem. I use it the same way you do, like this http://nsis.sourceforge.net/Examples/one-section.nsi

Always 1 checkbox is activated. You cant deactivate both.

Is it possible to uncheck both options with this "Sections.nsh" method?

HTML Code:
!include "Sections.nsh"
Name "One Section"
OutFile "one-section.exe"
RequestExecutionLevel user
; Pages
Page components
; Sections

Section !Required
  SectionIn RO

Section "Group 1 - Option 1" g1o1

Section /o "Group 1 - Option 2" g1o2

; Functions
; $1 stores the status of group 1

Function .onInit
  StrCpy $1 ${g1o1} ; Group 1 - Option 1 is selected by default

Function .onSelChange
  !insertmacro StartRadioButtons $1
    !insertmacro RadioButton ${g1o1}
    !insertmacro RadioButton ${g1o2}
  !insertmacro EndRadioButtons
Smurge is offline   Reply With Quote
Old 8th October 2013, 16:21   #3
Afrow UK
Afrow UK's Avatar
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You can write your own code in .onSelChange to check the selected states of sections and uncheck the others as necessary. You can use ${If} ${SectionIsSelected} and the UnselectSection macro in Sections.nsh to simplify things.

Afrow UK is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump