Fuzzybunny
1st November 2007 19:08 UTC
Radio buttons and Next Button
I've searched through the forums and i've found part of my answer however i still can't seem to get the Next button to be active.
If i had this ini:
[Settings]
NumFields=3
[Field 1]
Type=RadioButton
Text=Option1
Left=42
Right=-1
Top=11
Bottom=20
[Field 2]
Type=RadioButton
Text=Option2
Left=42
Right=-1
Top=33
Bottom=48
[Field 3]
Type=RadioButton
Text=Option3
Left=42
Right=-1
Top=59
Bottom=73
and my nsi was something like this:
Page custom ChooseSetup
.
.
.
Function ChooseSetup
;******Disable the NEXT button, until a radio button has been clicked
GetDlgItem $1 $HWNDPARENT 1
EnableWindow $1 0
!insertmacro MUI_HEADER_TEXT "Choose a Setup" "Choose which Setup you want to install."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "$PLUGINSDIR\SetupOptions.ini"
FunctionEnd
How do I enable the "Next" button once a radio button has been clicked? I've looked at testnotify.nsi, but if i did the "Page custom ChooseSetup ChooseSetup_Leaving" the ChooseSetup_Leaving only works if I left the page and thus have already clicked Next.
I thought if i did the follwing it would work:
ReadIniStr $0 '$PLUGINSDIR\SetupOptions.ini' "Field 1" "State"
ReadIniStr $1 '$PLUGINSDIR\SetupOptions.ini' "Field 2" "State"
ReadIniStr $2 '$PLUGINSDIR\SetupOptions.ini' "Field 3" "State"
${If} $1 == 1
${OrIf) $2 == 1
$(OrIf) $3 == 1
GetDlgItem $1 $HWNDPARENT 1
EnableWindow $1 0
${EndIf}
where am i going wrong? Thanks.
kichik
1st November 2007 19:57 UTC
You must use the NOTIFY flag on the radio buttons for the leave function to be called when they're clicked.
Fuzzybunny
1st November 2007 20:31 UTC
great thanks! but what if i didn't want to leave the page and i wanted them to have to click NEXT in order to get to the next page?
Afrow UK
1st November 2007 21:05 UTC
NOTIFY ensures the leave function is called. In there you need to check which radio button was selected (read from Settings>State to get the field # of the radio button). Call Abort to go back to the page, or rather to prevent the user leaving the page.
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 0
That will disable the next button.
Stu
Fuzzybunny
2nd November 2007 14:20 UTC
ok i tried what you suggested. However the is still something wrong. my leave function looks like this:
Function ChooseSetup_Leave
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 1
IntCmp $0 0 validate
Abort
validate:
MessageBox MB_ICONEXCLAMATION|MB_OK "Just a Message"
Abort
FunctionEnd
what happens is that when I select one of my radio buttons, it will automatically generate the MessageBox. The MessageBox should only appear when I hit Next. From what I've read 0 is the Next Button.
I'm using V2.1, if it helps.
Fuzzybunny
2nd November 2007 15:29 UTC
one more thing, because of the Abort in
.
.
.
validate:
MessageBox MB_ICONEXCLAMATION|MB_OK "You must select at least one install option!"
Abort
I also can't leave the page when I press Next.
Afrow UK
2nd November 2007 18:40 UTC
Page custom ChooseSetup ChooseSetupLeave
Function ChooseSetup
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 0
!insertmacro MUI_HEADER_TEXT "Choose a Setup" "Choose which Setup you want to install."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY SetupOptions.ini
FunctionEnd
Function ChooseSetupLeave
!insertmacro MUI_INSTALLOPTIONS_READ $R0 SetupOptions.ini Settings State
${If} $R0 == 1
${OrIf} $R0 == 2
${OrIf} $R0 == 3
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 1
Abort
${EndIf}
FunctionEnd
Stu
Fuzzybunny
2nd November 2007 18:52 UTC
awesome! thanks a bunch!