flyakite
21st October 2005 00:20 UTC
Check if SectionGroups are selected?
Okay I have 6 section groups in my installer with a whole bunch of sections in them. Basically I want to check on page leave if absolutely none (that are visible) are selected, so that I can alert the user that they didn't select anything (yes this actually happens, ALL the time).
I've checked out SectionGetFlags and SectionSetFlags in the docs but it doesn't make much sense to me. I don't get all the integer stuff, and there are no preset examples in the wiki. Someone should add a good example on how to simply check if a section is selected, and explain it in detail. Also the wiki says "Check one-section.nsi for examples of usage". I did check it out, it doesn't use either command in it at all. It only uses RadioButtons now.
I just need to know the command to simply check if a sectiongroup is selected. So I can check all the groups and then alert the user if needed.
Thanks.
Afrow UK
21st October 2005 09:07 UTC
Use the SectionFlagIsSet macro in Sections.nsh
!include Sections.nsh
...
LangString SELECT_COMPONENT ${LANG_ENGLISH} "Please select a component!"
...
Section "A Section" SEC01
SectionEnd
Section "Another Section" SEC02
SectionEnd
...
Function ComponentsLeave
!insertmacro SectionFlagIsSet ${SEC01} ${SF_SELECTED} End ""
!insertmacro SectionFlagIsSet ${SEC02} ${SF_SELECTED} End ""
MessageBox MB_OK|MB_ICONSTOP "$(SELECT_COMPONENT)"
Abort
End:
FunctionEnd
-Stu
flyakite
21st October 2005 16:18 UTC
Okay I get the idea, and your code works, kind of.
I just want to check if a section group is even partially selected. For instance, if the user selects even one item in a particular group, the check should pass and installation should continue instead of getting the alert.
With your method, the entire section group has to be selected. It does not account for a group where only item item out of five for example is selected. I hope there is a way to do this without running a check on every section, because I have about 200 or so.
kichik
21st October 2005 16:24 UTC
You can check for the SF_PSELECTED flag for that.
flyakite
21st October 2005 16:38 UTC
Ahh thanks, that worked perfect!
There really should be better documentation on this. None of those defines are documented as to what they actually do in the Sections.nsh file.
It would be nice to see a wiki page entirely about section control, because it seems like it has been asked a LOT, and there are so many different examples that do the same thing and stuff which has been phased out. Like SetSectionFlag saying to check out one-section.nsi, which now just uses the RadioButtons macro. A wiki page like:
- Checking if a section is selected or partially selected
- How to check or uncheck a section based on other items
- How to use the RadioButtons macro
- Clearing section flags
Etc. There is little detailed explanation in Sections.nsh, and there is nothing in the NSIS Documentation that says to look in Sections.nsh for omre functions. Without manually going through the NSIS program folder, most of this stuff isn't seen by the normal user.
I've searched the forums and found many people with the same questions, but the solutions are always different and generally tailored for their specific problem/code, and even then it's not really explained as to what is going on.
kichik
21st October 2005 16:44 UTC
For now, I've added a note about Sections.nsh to the documentation and description of the flags in Sections.nsh as well.
But it'd sure be nice if someone picked up the glove and created some order in the documentation for sections.