4
我有一個非常簡單的NSIS腳本,允許用戶選擇他們想要安裝的組件,但如果他們沒有選擇任何東西,我需要一種說「請選擇一個組件」的方式。NSIS - 驗證單選按鈕選擇
這裏的腳本:
# Based on the one-section example
# http://nsis.sourceforge.net/Examples/one-section.nsi
!include "sections.nsh"
Name "Humira & You"
OutFile "Humira & You - September 2012.exe"
RequestExecutionLevel user
Page components
Page instfiles
Section /o "Rheumatoid Arthritis" P1
File "/oname=$pluginsdir\Setup.msi" "setupfiles\Humira and you - Rheumatoid Arthritis.msi"
SectionEnd
Section /o "Psoriatic Arthritis" P2
File "/oname=$pluginsdir\Setup.msi" "setupfiles\Humira and you - Psoriatic Arthritis.msi"
SectionEnd
Section /o "Ankylosing Spondylitis" P3
File "/oname=$pluginsdir\Setup.msi" "setupfiles\Humira and you - Ankylosing Spondylitis.msi"
SectionEnd
Section /o "Axial Spondyloarthritis" P4
File "/oname=$pluginsdir\Setup.msi" "setupfiles\Humira and you - Axial Spondyloarthritis.msi"
SectionEnd
Section ; Hidden section that runs the show
DetailPrint "Installing selected application..."
SetDetailsPrint none
ExecWait '"msiexec" /i "$pluginsdir\Setup.msi"'
SetDetailsPrint lastused
SectionEnd
Function .onInit
Initpluginsdir ; Make sure $pluginsdir exists
StrCpy $1 ${P2} ;The default
FunctionEnd
Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${P1}
!insertmacro RadioButton ${P2}
!insertmacro RadioButton ${P3}
!insertmacro RadioButton ${P4}
!insertmacro EndRadioButtons
FunctionEnd
我身邊有一個外觀和行爲的這個例子來,http://nsis.sourceforge.net/Useful_InstallOptions_and_MUI_macros#Macro:_CHECKBOXCHECKER,但似乎因爲我想要的東西過於複雜。有沒有辦法說在NSIS:
if ($1.selectedIndex > -1) {
// continue
} else {
MessageBox.Show("Please select");
}
謝謝, 格雷格。
像夢一樣工作,謝謝! – gfyans