- NSIS Discussion
- how can i do this?
Archive: how can i do this?
goab
11th January 2006 02:44 UTC
how can i do this?
i have 4 sections,,
section1
section2
section3
section4
section1 is hidden, others are visible
they are in the same group
i want my installer to:
if the user select any section within 2-4, enable section1
if the user does not select any of section[2-4], disable section1
Please tell me how could i do this, thank you
Afrow UK
11th January 2006 16:50 UTC
Piece of cake. Assuming you are using Modern UI...
!include Sections.nsh
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsLeave
!insertmacro MUI_PAGE_COMPONENTS
...
Section "-section1" Sec1
SectionEnd
Section "section2" Sec2
SectionEnd
Section "section3" Sec3
SectionEnd
Section "section4" Sec4
SectionEnd
Function ComponentsLeave
!insertmacro SectionFlagIsSet ${Sec2} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec3} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec4} ${SF_SELECTED} SelectSection1 ""
!insertmacro UnselectSection ${Sec1}
Goto End
SelectSection1:
!insertmacro SelectSection ${Sec1}
End:
FunctionEnd
-Stu
goab
11th January 2006 20:50 UTC
thanks for your help but the code is not working
section1 is visible for testing, section1 is not always enabled when other sections are enabled, and i want auto disable section1 when no other section is enabled
!include Sections.nsh
!include MUI.nsh
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsLeave
!insertmacro MUI_PAGE_COMPONENTS
OutFile .\111.exe
Section "section1" Sec1
SectionEnd
Section "section2" Sec2
SectionEnd
Section "section3" Sec3
SectionEnd
Section "section4" Sec4
SectionEnd
Function ComponentsLeave
!insertmacro SectionFlagIsSet ${Sec2} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec3} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec4} ${SF_SELECTED} SelectSection1 ""
!insertmacro UnselectSection ${Sec1}
Goto End
SelectSection1:
!insertmacro SelectSection ${Sec1}
End:
FunctionEnd
Afrow UK
11th January 2006 20:54 UTC
1. Missing - in front of name in your code. It's in mine.
Section "-section1" Sec1
SectionEnd
2. You need !insertmacro MUI_PAGE_INSTFILES in there otherwise none of the Sections will be executed!
Edit: Oh and btw, when you mean 'disable' and 'enable' are you referring to selecting the section to be executed, or are you referring to enabling the section check-box so that the user can select or unselect it?
-Stu
goab
11th January 2006 23:50 UTC
1. Missing - in front of name in your code. It's in mine.
i deleted the "-" for testing, so i can see the status of the selection,
sorry my english is bad, when i say enable, it means select
i want my secton to look like
http://forums.winamp.com/showthread....hreadid=235097
but section1 is hidden, section2-4 depends on section1
if section2-4 is not selected(checked) auto uncheck section1
that means section1 cannot be installed alone
Afrow UK
12th January 2006 09:12 UTC
Oh I see. With the code above Section 1 will be selected if any 1 of the 3 (2-4) Sections are selected. If you need all three selected for Section 1 to be selected, then your ComponentsLeave function should look like this:
Function ComponentsLeave
!insertmacro SectionFlagIsSet ${Sec2} ${SF_SELECTED} 0 UnselectSection1
!insertmacro SectionFlagIsSet ${Sec3} ${SF_SELECTED} 0 UnselectSection1
!insertmacro SectionFlagIsSet ${Sec4} ${SF_SELECTED} SelectSection1 ""
UnselectSection1:
!insertmacro UnselectSection ${Sec1}
Goto End
SelectSection1:
!insertmacro SelectSection ${Sec1}
End:
FunctionEnd
-Stu
goab
12th January 2006 12:08 UTC
thank you
i did it, but i changed something and it worked
!include Sections.nsh
!insertmacro MUI_PAGE_COMPONENTS
...
Section "-section1" Sec1
SectionEnd
Section "section2" Sec2
SectionEnd
Section "section3" Sec3
SectionEnd
Section "section4" Sec4
SectionEnd
Function .onSelChange
!insertmacro SectionFlagIsSet ${Sec2} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec3} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec4} ${SF_SELECTED} SelectSection1 ""
!insertmacro UnselectSection ${Sec1}
Goto End
SelectSection1:
!insertmacro SelectSection ${Sec1}
End:
FunctionEnd
Afrow UK
12th January 2006 18:48 UTC
I didn't put it in .onSelChange because you won't see the changes made to Sec1 because Sec1 is hidden anyway. Therefore it would be bad coding practice to place the code there which will be called every time the user selects or unselects a section. It might as well be just when the user clicks Next instead...
-Stu
goab
12th January 2006 20:28 UTC
i think nsis should add a manual for section.nsi
or the manual is exist that i cannot find?