Archive: Radio buttons and Next Button


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.


You must use the NOTIFY flag on the radio buttons for the leave function to be called when they're clicked.


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?


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


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.


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.


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

awesome! thanks a bunch!