user2455111
user2455111

Reputation: 254

NSIS: Componesnts page on component checked event

I using NSIS to install my project. I need to show MessageBox with warning text, when I choosing some section to install on components page. Is there some way to track the click on the checkbox, may be event or something?

Upvotes: 1

Views: 606

Answers (1)

Anders
Anders

Reputation: 101636

Use the .onSelChange callback.

In NSIS 3 the changed section id is stored in $0:

Page Components
Page InstFiles

Section /o "Foo" SID_FOO
SectionEnd

Section "Bar"
SectionEnd

!include LogicLib.nsh

Function .onSelChange
${If} ${SectionIsSelected} ${SID_FOO}
${AndIf} $0 = ${SID_FOO}
    MessageBox MB_ICONEXCLAMATION "Warning, section Foo selected!"
${EndIf}
FunctionEnd

You have to track the state yourself in NSIS 2:

Page Components
Page InstFiles

Section /o "Foo" SID_FOO
SectionEnd

Section "Bar"
SectionEnd

!include LogicLib.nsh

Var hasWarned

Function .onSelChange
${If} ${SectionIsSelected} ${SID_FOO}
${AndIf} $hasWarned = 0
    StrCpy $hasWarned 1
    MessageBox MB_ICONEXCLAMATION "Warning, section Foo selected!"
${EndIf}
/* Uncomment this to display the warning every time it is selected
${IfNot} ${SectionIsSelected} ${SID_FOO}
    StrCpy $hasWarned 0
${EndIf}
*/
FunctionEnd

Upvotes: 1

Related Questions