Archive: SectionGroup selection problem


SectionGroup selection problem
I started working on my first NSIS installer and I basically need what Afro UK did in his "Two installations in one installer part 1.nsi" example. The only difference is that I want to be able to not install "Prog2" The condition I am trying to reach is if the sectiongroup is checked, The main program subsection is selected and RO. If the sectiongroup is unchecked, the main program subsection is unchecked. The actual code does not permit to completely unselect Prog2. If I remove the RO option, then I allow the user to install the options without installing the main program. Here's what I want:

[X]Prog2
---[X]Main (RO)
---[ ]Option1
---[ ]Option2

[ ]Prog2
---[ ]Main (RO)
---[ ]Option1
---[ ]Option2

I'm not sure this is possible. I tried to hide the main program section, but again I allow the user to install the options without installing the main program.


I have updated the code. The second group is no longer required.
http://nsis.sourceforge.net/archive/...instances=0,64

-Stu


Thanks for the update, but it is not really what I'm looking for. Removing "SectionIn RO" from the "Program #2" SectionGroup allow the user to completely unselect this group, but it also allows him to select only the "Other" subsection without selecting the "Main" subsection. I found this piece of code and it almost works for me. This is how I modified your code.


Var flags

Function .selTest
SectionGetFlags 1 $flags
StrCmp $flags 0 equal diff

diff:
SectionSetFlags 2 1
goto end

equal:
SectionSetFlags 2 ${SF_RO}
end:
FunctionEnd

Function .onSelChange
Call .selTest
FunctionEnd

The "Other" section is read-only until I check my main program. The only problem is that diff: sets the value of "Other". I would like it to simply reenable this section for me to choose if I want to enable it. Do you know how to do this? Would you also know how to apply this to both groups (right now it affects only "Program #1"?

Thanks a lot


So you want the Main section to be checked when the user checks the Other section?

This will do that (if I understood correctly):

Function .onSelChange
Push $R0
SectionGetFlags ${SEC4} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 ${SF_SELECTED} 0 NoSelectMain
!insertmacro SelectSection ${SEC3}
NoSelectMain:
Pop $R0
FunctionEnd


You shouldn't make the Main section read-only after though, because then you can't uncheck the whole section group in one go anymore.

The first group has to have a read only section, otherwise if the user doesn't select anything then nothing will be installed!

Edit: To turn off a flag, you need to use the ClearSectionFlag macro:
!insertmacro ClearSectionFlag ${SECID} ${SF_RO}

-Stu

I should have included the script from the beginning, it's gonna be much easier this way. Look at how the "Program #1" section reacts. If I disable Main, I cannot select other. My only problem is that when I reselect main I only want Other to become active, not permanently enabled. This is because of the part where I have

SectionSetFlags 2 1

What should I set it to to be able to modify it? If the user selects main, I want him to be able to select other, or not.


Nevermind Afro UK, your code works great. I was just not putting it in the right place in my script. I copied it before my sections were defined and that's why it didn't work.

I had another question regarding resuming installation after reboot. I saw a few thread on this topic so I'll post my question there.

Thanks again for your help.