Archive: Mutually exclusive radio buttons (i.e., single select)


Mutually exclusive radio buttons (i.e., single select)
This macro works with the radio button macros from Sections.nsh to allow only one of a set of buttons to be selected.

Here's how to call (must first handle .onInit):

!include "Sections.nsh" ; radio button macros
!include "mutex.nsi"
Function .onSelChange
!insertmacro StartMutexButtons $8
!insertmacro RadioButton ${MY_INDEX1}
!insertmacro RadioButton ${MY_INDEX2}
!insertmacro RadioButton ${MY_INDEX3}
!insertmacro EndMutexButtons
FunctionEnd

And here's the macro file:

; mutex.nsi
; Mutex button macros to complement radio buttons
; Smart Bear Software
;

!ifndef MUTEX_INCUDED
!define MUTEX_INCUDED

!macro StartMutexButtons var
!define StartRadioButtons_Var "${var}"

Push $R0
Push $R1

SectionGetFlags "${StartRadioButtons_Var}" $R1
IntOp $R0 $R1 & ${SECTION_OFF}
SectionSetFlags "${StartRadioButtons_Var}" $R0

Push $R2

StrCpy $R2 "${StartRadioButtons_Var}"

!macroend
!endif

!macro EndMutexButtons

StrCmp $R2 "${StartRadioButtons_Var}" 0 +2 ; selection hasn't changed
SectionSetFlags "${StartRadioButtons_Var}" $R1

Pop $R2
Pop $R1
Pop $R0

!undef StartRadioButtons_Var
!macroend


I can see that you've played with the Wiki sandbox, probably to learn how to create a Wiki page for this. Why didn't you create a page in the end?