Ilja
20th December 2005 20:44 UTC
RadioButton
Hi,
I have some Problems with radioButton.
I have following idea i will make the SecttionsGroup and allow to select only one. If the group contain two items it's all right, but if I have more Items and try to select/deselect group i get angry effect the selectio will be changed to all except one.
Have somebody idea ?
Thanks.
Afrow UK
21st December 2005 09:59 UTC
We need more information (like a script to reproduce the problem).
-Stu
Ilja
21st December 2005 12:38 UTC
my Source
# Auto-generated by EclipseNSIS Script Wizard
# 21.12.2005 13:32:10
Name TestApp
# Defines
!define REGKEY "SOFTWARE\$(^Name)"
# MUI defines
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-colorful.ico"
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_REGISTRY_KEY Software\TestApp
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup
!define MUI_STARTMENUPAGE_DEFAULT_FOLDER TestApp
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall-nsis.ico"
# Included files
!include Sections.nsh
!include MUI.nsh
!include LogicLib.nsh
# Reserved Files
# Variables
Var StartMenuGroup
# macrosdef
!macro SectionRadioButtons _d _e
Push $2
Push $3
Push $4
Push $5
Push $6
Push $7
!insertmacro StartRadioButtons ${_d}
StrCpy $3 0
StrLen $5 `${_e}`
${For} $2 0 $5
StrCpy $4 `${_e}` 1 $2
${If} $4 == ","
IntOp $3 $3 + 1
${EndIf}
${Next}
StrCpy $7 `${_e}`
StrCpy $4 0
${Do}
StrLen $5 `$7`
${For} $2 0 $5
StrCpy $6 `$7` 1 $2
${If} $6 == ","
StrCpy $6 `$7` $2
IntOp $2 $2 + 1
StrCpy $7 `$7` "" $2
IntOp $4 $4 + 1
${Break}
${EndIf}
${Next}
${If} $4 <= $3
${AndIf} $6 != ""
!insertmacro RadioButton $6
${If} $4 == $3
!insertmacro RadioButton $7
${EndIf}
${EndIf}
${LoopUntil} $4 >= $3
!insertmacro EndRadioButtons
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
!macroend
!macro RadioGetChecked _d _e
Push $2
Push $3
Push $4
Push $5
Push $6
Push $7
!ifndef _CheckedButton${_d}
var /GLOBAL _CheckedButton${_d}
!define _CheckedButton${_d}
!endif
StrCpy $3 0
StrLen $5 `${_e}`
${For} $2 0 $5
StrCpy $4 `${_e}` 1 $2
${If} $4 == ","
IntOp $3 $3 + 1
${EndIf}
${Next}
StrCpy $7 `${_e}`
StrCpy $4 0
${Do}
StrLen $5 `$7`
${For} $2 0 $5
StrCpy $6 `$7` 1 $2
${If} $6 == ","
StrCpy $6 `$7` $2
IntOp $2 $2 + 1
StrCpy $7 `$7` "" $2
IntOp $4 $4 + 1
${Break}
${EndIf}
${Next}
${If} $4 <= $3
${AndIf} $6 != ""
${If} ${SectionIsSelected} $6
StrCpy $_CheckedButton${_d} "$6"
${ExitDo}
${EndIf}
${If} $4 == $3
${AndIf} ${SectionIsSelected} $7
StrCpy $_CheckedButton${_d} "$7"
${EndIf}
${EndIf}
${LoopUntil} $4 >= $3
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
!macroend
# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
# Installer languages
!insertmacro MUI_LANGUAGE English
!insertmacro MUI_LANGUAGE German
# Installer attributes
OutFile TestAppSetup.exe
InstallDir $PROGRAMFILES\TestApp
CRCCheck on
XPStyle on
ShowInstDetails show
InstallDirRegKey HKLM "${REGKEY}" Path
ShowUninstDetails show
# Installer sections
Section -Main SEC0000
SetOutPath $INSTDIR
SetOverwrite on
File ..\..\..\Test\main
WriteRegStr HKLM "${REGKEY}\Components" Main 1
SectionEnd
SectionGroup Database SECGRP0000
Section DemoDatabase SEC0001
SetOutPath $INSTDIR
SetOverwrite on
File ..\..\..\Test\demo.txt
WriteRegStr HKLM "${REGKEY}\Components" DemoDatabase 1
SectionEnd
Section DefaultLocal SEC0002
SetOutPath $INSTDIR
SetOverwrite on
File ..\..\..\Test\default.txt
WriteRegStr HKLM "${REGKEY}\Components" DefaultLocal 1
SectionEnd
Section "!No Database" SEC0003
SetOutPath $INSTDIR
SetOverwrite on
File ..\..\..\Test\noDB.txt
WriteRegStr HKLM "${REGKEY}\Components" "No Database" 1
SectionEnd
SectionGroupEnd
Section -post SEC0004
WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
WriteUninstaller $INSTDIR\TestAppUninstall.exe
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
SetOutPath $SMPROGRAMS\$StartMenuGroup
CreateShortCut "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk" $INSTDIR\TestAppUninstall.exe
!insertmacro MUI_STARTMENU_WRITE_END
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\TestAppUninstall.exe
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\TestAppUninstall.exe
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
SectionEnd
# Macro for selecting uninstaller sections
!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
Push $R0
ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
StrCmp $R0 1 0 next${UNSECTION_ID}
!insertmacro SelectSection "${UNSECTION_ID}"
Goto done${UNSECTION_ID}
next${UNSECTION_ID}:
!insertmacro UnselectSection "${UNSECTION_ID}"
done${UNSECTION_ID}:
Pop $R0
!macroend
# Uninstaller sections
Section /o "un.No Database" UNSEC0003
Delete /REBOOTOK $INSTDIR\noDB.txt
DeleteRegValue HKLM "${REGKEY}\Components" "No Database"
SectionEnd
Section /o un.DefaultLocal UNSEC0002
Delete /REBOOTOK $INSTDIR\default.txt
DeleteRegValue HKLM "${REGKEY}\Components" DefaultLocal
SectionEnd
Section /o un.DemoDatabase UNSEC0001
Delete /REBOOTOK $INSTDIR\demo.txt
DeleteRegValue HKLM "${REGKEY}\Components" DemoDatabase
SectionEnd
Section /o un.Main UNSEC0000
Delete /REBOOTOK $INSTDIR\main
DeleteRegValue HKLM "${REGKEY}\Components" Main
SectionEnd
Section un.post UNSEC0004
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk"
Delete /REBOOTOK $INSTDIR\TestAppUninstall.exe
DeleteRegValue HKLM "${REGKEY}" StartMenuGroup
DeleteRegValue HKLM "${REGKEY}" Path
DeleteRegKey /ifempty HKLM "${REGKEY}\Components"
DeleteRegKey /ifempty HKLM "${REGKEY}"
RMDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
RMDir /REBOOTOK $INSTDIR
SectionEnd
# Installer functions
Function .onInit
InitPluginsDir
FunctionEnd
# Uninstaller functions
Function un.onInit
SetAutoClose true
ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
ReadRegStr $StartMenuGroup HKLM "${REGKEY}" StartMenuGroup
!insertmacro SELECT_UNSECTION Main ${UNSEC0000}
!insertmacro SELECT_UNSECTION DemoDatabase ${UNSEC0001}
!insertmacro SELECT_UNSECTION DefaultLocal ${UNSEC0002}
!insertmacro SELECT_UNSECTION "No Database" ${UNSEC0003}
FunctionEnd
Function .onSelChange
!insertmacro SectionRadioButtons "${SEC0001}" "${SEC0001}, ${SEC0002}, ${SEC0003}"
FunctionEnd
# Installer Language Strings
# TODO Update the Language Strings with the appropriate translations.
LangString ^UninstallLink ${LANG_ENGLISH} "Uninstall $(^Name)"
LangString ^UninstallLink ${LANG_GERMAN} "Uninstall $(^Name)"
Afrow UK
21st December 2005 13:42 UTC
I'm confused here... what are all these macros for.
Check out Examples\one-section.nsi
-Stu
Ilja
21st December 2005 14:55 UTC
Check out Examples\one-section.nsi
This example allow to use the radiobuttons which are not grouped in the SectionGroup. But I need to group disjunct sections.
Ilja
2nd January 2006 15:18 UTC
Thanks.
It is exactly what I required.