I'm trying to disable/enable a text field when a radio button is selected, as part of a ModernUI Installer with custom page.
The page:
[Settings]
NumFields=4
[Field 1]
Type=Label
Text=Instance
Left=10
Right=38
Top=9
Bottom=17
[Field 2]
Type=RadioButton
Text=Default
Flags=GROUP|NOTIFY
State=1
Left=50
Right=125
Top=9
Bottom=19
[Field 3]
Type=RadioButton
Text=Named Instance
Flags=NOTIFY
State=0
Left=50
Right=125
Top=22
Bottom=32
[Field 4]
Type=Text
MaxLen=20
Flags=DISABLED
Left=128
Right=251
Top=20
Bottom=33
The NSI file (selected parts):
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Components page
!insertmacro MUI_PAGE_COMPONENTS
Page custom InstancePage InstancePageLeave
(...)
Function .onInit
;Extract InstallOptions INI files
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "Instance.ini"
FunctionEnd
LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Application Instance"
LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "Select an application instance to install or upgrade."
Function InstancePage
!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "Instance.ini"
FunctionEnd
Function InstancePageLeave
; At this point the user has either pressed Next or one of our custom buttons
; We find out which by reading from the INI file
!insertmacro MUI_INSTALLOPTIONS_READ $0 "Instance.ini" "Settings" "State"
StrCmp $0 2 defaultinstance ; "default instance name"?
StrCmp $0 3 namedinstance ; "non-default instance name"?
Abort ; Return to the page
defaultinstance:
; Make the FileRequest field depend on the first checkbox
!insertmacro MUI_INSTALLOPTIONS_WRITE "Instance.ini" "Field 4" "Flags" "GROUP|DISABLED"
Abort ; Return to the page
namedinstance:
; Make the FileRequest field depend on the first checkbox
!insertmacro MUI_INSTALLOPTIONS_WRITE "Instance.ini" "Field 4" "Flags" "GROUP"
!insertmacro MUI_INSTALLOPTIONS_WRITE "Instance.ini" "Field 4" "State" "Default"
Abort ; Return to the page
FunctionEnd
The !insertmacro after the two labels defaultinstance and namedinstance just don't seem to work. Field 4 remains disabled no matter what...
Thanks for any help
Can't get Notify of control to work with MUI
3 posts
for classic gui this trick works fine for me, yet, has not been tested with MUI. Give it a try.
Function InstancePage
;pop $R0
strcmp $R0 'reload1' +1 elseif
InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\Instance.ini"
!insertmacro MUI_INSTALLOPTIONS_WRITE "$PLUGINSDIR\Instance.ini" "Field 4" "Flags" "GROUP"
!insertmacro MUI_INSTALLOPTIONS_WRITE "$PLUGINSDIR\Instance.ini" "Field 4" "State" "Default"
!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
InstallOptions::show
goto end
elseif:
strcmp $R0 'reload' +1 else
InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\Instance.ini"
!insertmacro MUI_INSTALLOPTIONS_WRITE "$PLUGINSDIR\Instance.ini" "Field 4" "Flags" "GROUP|DISABLED"
!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
InstallOptions::show
goto end
else:
!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
InstallOptions::dialog '$PLUGINSDIR\Instance.ini"
end:
FunctionEnd
Function InstancePageLeave
; At this point the user has either pressed Next or one of our custom buttons
; We find out which by reading from the INI file
!insertmacro MUI_INSTALLOPTIONS_READ $0 "$PLUGINSDIR\Instance.ini" "Settings" "State"
StrCmp $0 2 defaultinstance ; "default instance name"?
StrCmp $0 3 namedinstance ; "non-default instance name"?
Abort ; Return to the page
defaultinstance:
; Make the FileRequest field depend on the first checkbox
;!insertmacro MUI_INSTALLOPTIONS_WRITE "Instance.ini" "Field 4" "Flags" "GROUP|DISABLED"
strcpy $R0 'reload'
Abort ; Return to the page
namedinstance:
; Make the FileRequest field depend on the first checkbox
;!insertmacro MUI_INSTALLOPTIONS_WRITE "Instance.ini" "Field 4" "Flags" "GROUP"
;!insertmacro MUI_INSTALLOPTIONS_WRITE "Instance.ini" "Field 4" "State" "Default"
strcpy $R0 'reload1'
Abort ; Return to the page
FunctionEnd
You have to use EnableWindow to enable/disable control rigth away, setting flag in INI is not enough.
See ${NSISDIR}\Examples\InstallOptions\testnotify.nsi
See ${NSISDIR}\Examples\InstallOptions\testnotify.nsi