- NSIS Discussion
- 1st group "choose 1 of 3", 2nd group "choose 1 of 2"
Archive: 1st group "choose 1 of 3", 2nd group "choose 1 of 2"
mk2007
15th September 2007 19:10 UTC
1st group "choose 1 of 3", 2nd group "choose 1 of 2"
The problem is in the title.
A group with 3 alternative options is not the problem. But a group with only 2 options does not work. I did not find any solution in the forums. I found lots of examples with 3 options, but no example of a group with 2 options.
Here is my script, you can check yourself what is wrong. Thank you for your support:
--------------------------------------------------------
Name "TEST"
Caption "TEST"
!include "Sections.nsh"
!include "logiclib.nsh"
OutFile "TEST.exe"
InstallDirRegKey HKCU "Housemarque\Installer" "SUPREME_IDIR"
SetDateSave on
SetDatablockOptimize on
CRCCheck on
SilentInstall normal
BGGradient 000033 000033 000033
InstallColors 000000 FFFFFF
XPStyle on
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
SectionGroup "Group 1"grp1
Section "1a"g1o1
SetOutPath $INSTDIR\
File /r "E:\Nullsoft\TEST\1\*.*"
SectionEnd
Section /o "1b"g1o2
SetOutPath $INSTDIR\
File /r "E:\Nullsoft\TEST\2\*.*"
SectionEnd
Section /o "1c"g1o3
SetOutPath $INSTDIR\
File /r "E:\Nullsoft\TEST\3\*.*"
SectionEnd
SectionGroupEnd
SectionGroup "Group 2"grp2
Section "2a"g2o1
SetOutPath $INSTDIR\
File /r "E:\Nullsoft\TEST\4\*.*"
SectionEnd
Section /o "2b"g2o2
SetOutPath $INSTDIR\
File /r "E:\Nullsoft\TEST\5\*.*"
SectionEnd
SectionGroupEnd
Function .onInit
StrCpy $1 ${g1o1}
StrCpy $2 ${g2o1}
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}
${EndIf}
!insertmacro StartRadioButtons $2
!insertmacro RadioButton ${g2o1}
!insertmacro RadioButton ${g2o2}
!insertmacro EndRadioButtons
FunctionEnd
ImBcmDth
15th September 2007 22:32 UTC
If you remove the two code-blocks surrounded by:
{$If} $R0 == ${SF_SELECTED}
.
.
.
${EndIf}
It seems to work fine for me. I couldn't figure out what exactly was the purpose of those two code blocks. I commented them out and was pleasantly surprised that it worked.
Jon
mk2007
15th September 2007 22:45 UTC
Originally posted by ImBcmDth
If you remove the two code-blocks surrounded by:
{$If} $R0 == ${SF_SELECTED}
.
.
.
${EndIf}
It seems to work fine for me. I couldn't figure out what exactly was the purpose of those two code blocks. I commented them out and was pleasantly surprised that it worked.
Jon
Now it is 50 percent correct at Group 2 (because nothing should happen when you click at the Group 2 check box!), but now it is completely wrong at Group 1.
So, this - unfortunately - is not the solution.
Can anyone help?
ImBcmDth
15th September 2007 23:15 UTC
Whoops! I never tested clicking on the section group buttons. I have never done any section stuff before but the changes I made code sets up the groups to be be unchangeable so the only thing you need to worry about in .onSelChange are the states of the 3 or 2 check boxes:
Function .onInit
; Setup the group check boxes to be:
; SF_RO: Make Required (already checked)
; SF_SECGRP: Make section group parent (from default settings)
; SF_PSELECTED: Partial selection (default = SF_SELECTED which is not right)
; SF_EXPANDED: Make already expanded
IntOp $0 ${SF_PSELECTED} | ${SF_RO}
IntOp $0 $0 | ${SF_SECGRP}
IntOp $0 $0 | ${SF_EXPAND}
SectionSetFlags ${grp1} $0
SectionSetFlags ${grp2} $0
; Set the pre-selected options
StrCpy $1 ${g1o1}
StrCpy $2 ${g2o1}
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1}
!insertmacro RadioButton ${g1o2}
!insertmacro RadioButton ${g1o3}
!insertmacro EndRadioButtons
!insertmacro StartRadioButtons $2
!insertmacro RadioButton ${g2o1}
!insertmacro RadioButton ${g2o2}
!insertmacro EndRadioButtons
FunctionEnd
Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1}
!insertmacro RadioButton ${g1o2}
!insertmacro RadioButton ${g1o3}
!insertmacro EndRadioButtons
!insertmacro StartRadioButtons $2
!insertmacro RadioButton ${g2o1}
!insertmacro RadioButton ${g2o2}
!insertmacro EndRadioButtons
FunctionEnd
Hopefully, this is closer to what you intend to accomplish.
Jon
mk2007
15th September 2007 23:50 UTC
Originally posted by ImBcmDth
Whoops! I never tested clicking on the section group buttons. I have never done any section stuff before but the changes I made code sets up the groups to be be unchangeable so the only thing you need to worry about in .onSelChange are the states of the 3 or 2 check boxes:
Function .onInit
; Setup the group check boxes to be:
; SF_RO: Make Required (already checked)
; SF_SECGRP: Make section group parent (from default settings)
; SF_PSELECTED: Partial selection (default = SF_SELECTED which is not right)
; SF_EXPANDED: Make already expanded
IntOp $0 ${SF_PSELECTED} | ${SF_RO}
IntOp $0 $0 | ${SF_SECGRP}
IntOp $0 $0 | ${SF_EXPAND}
SectionSetFlags ${grp1} $0
SectionSetFlags ${grp2} $0
; Set the pre-selected options
StrCpy $1 ${g1o1}
StrCpy $2 ${g2o1}
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1}
!insertmacro RadioButton ${g1o2}
!insertmacro RadioButton ${g1o3}
!insertmacro EndRadioButtons
!insertmacro StartRadioButtons $2
!insertmacro RadioButton ${g2o1}
!insertmacro RadioButton ${g2o2}
!insertmacro EndRadioButtons
FunctionEnd
Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1}
!insertmacro RadioButton ${g1o2}
!insertmacro RadioButton ${g1o3}
!insertmacro EndRadioButtons
!insertmacro StartRadioButtons $2
!insertmacro RadioButton ${g2o1}
!insertmacro RadioButton ${g2o2}
!insertmacro EndRadioButtons
FunctionEnd
Hopefully, this is closer to what you intend to accomplish.
Jon
I only have to remove the red line:
IntOp $0 $0 | ${SF_EXPAND}
and I get EXACTLY what I was looking for! :)
You helped a lot! Thank you very much! :up:
mk2007
16th September 2007 00:27 UTC
Advanced version: "choose maximum 1 of each group".
For example Group 2: I want to install either one of the two options, or (new: ) none of the two. Just now it is impossible to unclick the check boxes. Do you know a solution for my installer?
mk2007
17th September 2007 19:21 UTC
I repeat my last question, and I really hope that someone can help me:
I have a group with several options (parameters g1o1, g1o2 and so on), but I am looking for the option to uncheck all of them! Because sometimes want to install not one of the group, but nothing!
I think that everyone can understand what I mean. Does anyone have a solution for me?
To the admins: It makes no sense that you allow me editing my last post only within 180 minutes.