On my MUI Components Page I call a function when the users attempts to leave that page. In that function I am trying to see that there is atleast 1 component checked. If there isn't then I show a MessageBox and abort(stop from continuing to the next page).
My Problem: My function always says a component is checked even when it isn't. What am I doing wrong?
For some reason the program always thinks the 1st component is checked/selected when it is not?
!include nsdialogs.nsh
!include MUI2.nsh
!define MUI_PAGE_CUSTOMFUNCTION_SHOW compshow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE compleave
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_LANGUAGE "English"
OutFile "test.exe"
Function compshow
FunctionEnd
Function compleave
!insertmacro SectionFlagIsSet ${section1} ${SF_SELECTED} +1 +2
MessageBox MB_OK "Component Selected"
MessageBox MB_OK "Component NOT Selected"
FunctionEnd
Section "Dummy1"
SectionEnd
Section "Dummy2"
SectionEnd
Your problem is with relative jumps. You should use some labels instead because macros may contain many commands, not just one.
Also, think that the execution will continue after the first jump. Dont forget to skip the other branch of the test.
The modified compleave
callback works as you intended :
Function compleave
!insertmacro SectionFlagIsSet ${section1} ${SF_SELECTED} selected not_selected
selected:
MessageBox MB_OK "Component Selected"
goto end
not_selected:
MessageBox MB_OK "Component NOT Selected"
end:
FunctionEnd