Archive: Select Sectiongroup with Radiobutton


Select Sectiongroup with Radiobutton
Hello
I have a selection Group
with 4 entries

This four entries should behave like radioButtons
So at least one of the RadioButtons have to be selected


The problem is, if I click on the selectionButton of the group
several "Sub"Sections are selected

like in the attached picture (Red marked is the group)

My .onSelChange Function..

Function .onSelChange
!insertmacro StartRadioButtons $Matlabver
!insertmacro RadioButton ${SEC0016}
!insertmacro RadioButton ${SEC0013}
!insertmacro RadioButton ${SEC0014}
!insertmacro RadioButton ${SEC0015}
!insertmacro EndRadioButtons
FunctionEnd

I following example, once you click on a group default settings restored.


; 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"
!include "logiclib.nsh"

;--------------------------------

Name "One Section"
OutFile "one-section.exe"

;--------------------------------

; Pages

Page components

;--------------------------------

; Sections

Section !Required
SectionIn RO
SectionEnd

SectionGroup /e "Group 1" grp1
Section "Group 1 - Option 1" g1o1
SectionEnd

Section /o "Group 1 - Option 2" g1o2
SectionEnd

Section /o "Group 1 - Option 3" g1o3
SectionEnd
SectionGroupEnd

SectionGroup /e "Group 2" grp2
Section "Group 2 - Option 1" g2o1
SectionEnd

Section /o "Group 2 - Option 2" g2o2
SectionEnd

Section /o "Group 2 - Option 3" g2o3
SectionEnd
SectionGroupEnd
;--------------------------------

; Functions

; $1 stores the status of group 1
; $2 stores the status of group 2

Function .onInit

StrCpy $1 ${g1o1} ; Group 1 - Option 1 is selected by default
StrCpy $2 ${g2o1} ; Group 2 - Option 1 is selected by default

FunctionEnd

Function .onSelChange

SectionGetFlags ${grp1} $R0
IntOp $R0 $R0 & ${SF_SELECTED}

${If} $R0 == ${SF_SELECTED}
!insertmacro SelectSection ${g1o1}
!insertmacro UnSelectSection ${g1o2}
!insertmacro UnSelectSection ${g1o3}
${EndIf}

!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1}
!insertmacro RadioButton ${g1o2}
!insertmacro RadioButton ${g1o3}
!insertmacro EndRadioButtons

SectionGetFlags ${grp2} $R0
IntOp $R0 $R0 & ${SF_SELECTED}

${If} $R0 == ${SF_SELECTED}
!insertmacro SelectSection ${g2o1}
!insertmacro UnSelectSection ${g2o2}
!insertmacro UnSelectSection ${g2o3}
${EndIf}

!insertmacro StartRadioButtons $2
!insertmacro RadioButton ${g2o1}
!insertmacro RadioButton ${g2o2}
!insertmacro RadioButton ${g2o3}
!insertmacro EndRadioButtons

FunctionEnd

Problem solved
Hi Red Wine!
Thank you, I found the error
I forgot to reset the Flags

SectionGetFlags ${grp1} $R0
IntOp $R0 $R0 & ${SF_SELECTED}

${If} $R0 == ${SF_SELECTED}
!insertmacro SelectSection ${g1o1}
!insertmacro UnSelectSection ${g1o2}
!insertmacro UnSelectSection ${g1o3}
${EndIf}


But now i have onother question

I want that the click on the Grp Icon' doesn't change the selection..
is this possible?
I used the following code, but i doesn't change the behavior

what I'm doing wrong?
 ${If} $R0 == ${SF_SELECTED}
${switch} $Matlabver
${Case} ${SEC0016}
!insertmacro SelectSection ${SEC0016}
!insertmacro UnSelectSection ${SEC0013}
!insertmacro UnSelectSection ${SEC0014}
!insertmacro UnSelectSection ${SEC0015}
${Case} ${SEC0013}
!insertmacro SelectSection ${SEC0013}
!insertmacro UnSelectSection ${SEC0016}
!insertmacro UnSelectSection ${SEC0015}
!insertmacro UnSelectSection ${SEC0014}
${Case} ${SEC0014}
!insertmacro SelectSection ${SEC0014}
!insertmacro UnSelectSection ${SEC0016}
!insertmacro UnSelectSection ${SEC0013}
!insertmacro UnSelectSection ${SEC0015}
${Case} ${SEC0015}
!insertmacro SelectSection ${SEC0015}
!insertmacro UnSelectSection ${SEC0016}
!insertmacro UnSelectSection ${SEC0013}
!insertmacro UnSelectSection ${SEC0014}
${Default}
!insertmacro SelectSection ${SEC0016}
!insertmacro UnSelectSection ${SEC0015}
!insertmacro UnSelectSection ${SEC0013}
!insertmacro UnSelectSection ${SEC0014}
${EndSwitch}
${EndIf}

I want that the click on the Grp Icon' doesn't change the selection..
is this possible?
I haven't tested something like this so I couldn't confirm, but, as far as I know NSIS, must be possible, just give it some try.

My first Problem was, that I added one of the section in the radiobutton group to an installtype
This is a NO-NO!!!
but here is a onselchange which solves the problem
simple select the right section when the section grp get activated

Function .onSelChange
SectionGetFlags ${SECGRP0002} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
${If} $R0 == ${SF_SELECTED}
${select} $Matlabver
${Case} ${SEC0016}
!insertmacro SelectSection ${SEC0016}
!insertmacro UnSelectSection ${SEC0013}
!insertmacro UnSelectSection ${SEC0014}
!insertmacro UnSelectSection ${SEC0015}
${Case} ${SEC0013}
!insertmacro SelectSection ${SEC0013}
!insertmacro UnSelectSection ${SEC0016}
!insertmacro UnSelectSection ${SEC0015}
!insertmacro UnSelectSection ${SEC0014}
${Case} ${SEC0014}
!insertmacro SelectSection ${SEC0014}
!insertmacro UnSelectSection ${SEC0016}
!insertmacro UnSelectSection ${SEC0013}
!insertmacro UnSelectSection ${SEC0015}
${Case} ${SEC0015}
!insertmacro SelectSection ${SEC0015}
!insertmacro UnSelectSection ${SEC0016}
!insertmacro UnSelectSection ${SEC0013}
!insertmacro UnSelectSection ${SEC0014}
${Default}
!insertmacro SelectSection ${SEC0016}
!insertmacro UnSelectSection ${SEC0015}
!insertmacro UnSelectSection ${SEC0013}
!insertmacro UnSelectSection ${SEC0014}
${EndSelect}
${EndIf}

!insertmacro StartRadioButtons $Matlabver
!insertmacro RadioButton ${SEC0013}
!insertmacro RadioButton ${SEC0014}
!insertmacro RadioButton ${SEC0015}
!insertmacro RadioButton ${SEC0016}
!insertmacro EndRadioButtons
FunctionEnd