Cyrus XIII
19th August 2005 02:18 UTC
Require user to choose one component
Hi,
I'm writing an installer with four components, all optional. Now I'd like people to be stopped and prompted to select at least one of them upon leaving the component page.
I already know that this can be done by associationg the respective function like this
Page Components "" "" MyFunction
but I just can't come up with a function that does the job properly.
JasonFriday13
19th August 2005 05:53 UTC
I have put together an example barebones script that works. it uses pageex for the components page because it needs the callback function of leaving the page. Here's the example script and it's exe.
EDIT: Forget about the pageex and use the function described above. I didn't realize a page command could use function calls as well as custom pages.
Afrow UK
19th August 2005 10:55 UTC
Simpler:
!include Sections.nsh
Page Components "" "" ComponentsLeaveFunc
Section "A section" SEC1
SectionEnd
Section "A section" SEC2
SectionEnd
Function ComponentsLeaveFunc
!insertmacro SectionFlagIsSet ${SEC1} ${SF_SELECTED} End ""
!insertmacro SectionFlagIsSet ${SEC2} ${SF_SELECTED} End ""
MessageBox MB_OK|MB_ICONSTOP "Select atleast one component."
Abort
End:
FunctionEnd
-Stu
kichik
19th August 2005 12:55 UTC
Simpler:
!include LogicLib.nsh
Page Components "" "" ComponentsLeaveFunc
Section "A section" SEC1
SectionEnd
Section "A section" SEC2
SectionEnd
Function ComponentsLeaveFunc
${Unless} ${SectionIsSelected} ${SEC1}
${AndUnless} ${SectionIsSelected} ${SEC2}
MessageBox MB_OK|MB_ICONSTOP "Select atleast one component."
Abort
${EndUnless}
FunctionEnd
:)
Cyrus XIII
20th August 2005 01:27 UTC
So far I tried Jason's solution and it worked like a charm. But I might play around with the other two later on to thin out the code.
Anyway, thx to all of you. :)
JasonFriday13
22nd August 2005 07:06 UTC
The extra stuff in the .oninit function sets the components page checkboxes to not checked so the end user HAS to choose one option before continuing.
Afrow UK
22nd August 2005 10:57 UTC
You should use Section /o for that.
Similarely, Section flags (with SectionGetFlags) are not always going to be "1" (the flags specify more than the selected state).
-Stu
JasonFriday13
23rd August 2005 01:20 UTC
Yes, I know that. But I just don't know what the return value should look like if several settings are set and you call SectionGetFlags.