What specifies the order that sections appear as options when the user views the list of components he can check/uncheck, just prior to starting the install?
I had thought it was the order the sections appear in the NSIS file, but apparently that is not the case... A section that is pretty far down in my .nsi file now appears at the top of the list the user sees, for some reason.
Note that it is initially a hidden section (name of "") that we give a name in .onInit() if it's turned on, so that it appears. Does this result it in moving to the top of the list?
I'd like it to appear near the bottom of the list. How can I control its order, even if I need to change it from being a hidden section to a visible section during .onInit()?
What determines NSIS Section order?
5 posts
I cannot reproduce this:
Section FooWhat if the section has a name and you remove the name instead?
SectionEnd
Section -Bar SID_BAR
SectionEnd
Section Baz
SectionEnd
Function .onInit
SectionSetText ${SID_BAR} "Bar"
FunctionEnd
Page Components
Page InstFiles
Thanks! You're right -- I couldn't duplicate it with your script either.
After poking around with it a bit longer, I realized it's not a matter of the section moving out-of-place, but rather an issue where if you put your .onInit() higher up in the script than the Sections, and then call SectionSetText, it will rename the top-most section instead of the section you specify.
Example:
Here the call to:
SectionSetText ${section_to_rename} "This is the renamed section"
behaves as if you had instead done this:
SectionSetText ${section_hidden} "This is the renamed section"
The solution is to move .onInit() lower in the file, after the sections. I had moved it higher, so the installer might start up faster.
Is this a bug in nsis, an undocumented restriction, or just something that IS documented, that I missed?
After poking around with it a bit longer, I realized it's not a matter of the section moving out-of-place, but rather an issue where if you put your .onInit() higher up in the script than the Sections, and then call SectionSetText, it will rename the top-most section instead of the section you specify.
Example:
!include MUI2.nsh # Modern User Interface (2.0)
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
Function .onInit
SectionSetText ${section_to_rename} "This is the renamed section"
FunctionEnd
OutFile "out\test.exe"
Section "-hidden section" section_hidden
SectionEnd
Section /o "" section_to_rename
SectionEnd
Section Three section_three
SectionEnd
# This handles Description text on the Select Components page
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${section_to_rename} "Description for section that is to be renamed."
!insertmacro MUI_DESCRIPTION_TEXT ${section_hidden} "This is the hidden section. Should NOT be visible!"
!insertmacro MUI_DESCRIPTION_TEXT ${section_three} "Section three"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Page Components
Page InstFiles
Here the call to:
SectionSetText ${section_to_rename} "This is the renamed section"
behaves as if you had instead done this:
SectionSetText ${section_hidden} "This is the renamed section"
The solution is to move .onInit() lower in the file, after the sections. I had moved it higher, so the installer might start up faster.
Is this a bug in nsis, an undocumented restriction, or just something that IS documented, that I missed?
The section index define is not defined until the section command in the .nsi has been parsed, if you try to use the section index before that it is not going to work.
From the docs:
From the docs:
To access the section index, curly brackets must be used and the code must be located below the section in the script.NSIS 2.4x should issue a warning and 3.0 Beta will fail with a error...
Ahh, so user error. Good to know, thanks!