- NSIS Discussion
- Installation with Components Choise
Archive: Installation with Components Choise
pegase06
20th March 2007 12:08 UTC
Installation with Components Choise
Hello,
In MUI_PAGE_COMPONENTS, I have
SectionGroup /e "Section 1" SEC01
Section "Section 1.1" SEC011
...
SectionEnd
Section "Section 1.2" SEC012
...
SectionEnd
Section "Section 1.2" SEC013
...
SectionEnd
SectionGroupEnd
The user can chose only one sub section (Section 1.1 or Section 1.2 or Section 1.3) or nothing.
How do it ?
Thanks.
Red Wine
20th March 2007 12:23 UTC
If nothing in the above sample then what the installer is going to install?
Is there a hidden or read only section outside that group which is always installed?
I think included example one-section.nsi could be your starting point.
pegase06
20th March 2007 14:14 UTC
Originally posted by Red Wine
]If nothing in the above sample then what the installer is going to install?
There is too a required section.
Originally posted by Red Wine
Is there a hidden or read only section outside that group which is always installed?
I think included example one-section.nsi could be your starting point.
That group is not required and can be not installed.
The first section install start menu for all user, the second section install start menu for current user. And if the user doesn't want start menu, none section is selected.
Section "Program" SEC00
SectionIn RO
...
SectionEnd
SectionGroup /e "Start menu" SEC01
Section "All user" SEC011
...
SectionEnd
Section "Current user" SEC012
...
SectionEnd
SectionGroupEnd
jholguin
20th March 2007 14:40 UTC
In your NSIS directory, in the 'Examples' Folder there's a nsi file called one-section.nsi which does this. It seems to work by turning the items into radio buttons which by default can only have 1 per "group" selected.
Here's the pertinent code:
Section "Group 1 - Option 1" g1o1
SectionEnd
Section /o "Group 1 - Option 2" g1o2
SectionEnd
Section /o "Group 1 - Option 3" g1o3
SectionEnd
Section "Group 2 - Option 1" g2o1
SectionEnd
Section /o "Group 2 - Option 2" g2o2
SectionEnd
Section /o "Group 2 - Option 3" g2o3
SectionEnd
;--------------------------------
; Functions
; $1 stores the status of group 1
; $2 stores the status of group 2
Function .onInit
StrCpy $1 ${g1o1} ; Group 1 - Option 1 is selected by default
StrCpy $2 ${g2o1} ; Group 2 - Option 1 is selected by default
FunctionEnd
Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1}
!insertmacro RadioButton ${g1o2}
!insertmacro RadioButton ${g1o3}
!insertmacro EndRadioButtons
!insertmacro StartRadioButtons $2
!insertmacro RadioButton ${g2o1}
!insertmacro RadioButton ${g2o2}
!insertmacro RadioButton ${g2o3}
!insertmacro EndRadioButtons
FunctionEnd
pegase06
20th March 2007 14:46 UTC
Originally posted by jholguin
In your NSIS directory, in the 'Examples' Folder there's a nsi file called one-section.nsi which does this. It seems to work by turning the items into radio buttons which by default can only have 1 per "group" selected.
Here's the pertinent code
I have try this code, but I can't unselect a sub section.
I need the possibility to have alle sub section unselect.
Red Wine
20th March 2007 14:57 UTC
outfile 'test.exe'
!include "Sections.nsh"
!include "LogicLib.nsh"
Insttype "/CUSTOMSTRING=Please either select one option or none"
Insttype "Option one"
Insttype "option two"
page components
page instfiles
Section "Common FIles (Required)"
SectionIn RO 1 2
# common files here
SectionEnd
SectionGroup /e "Select an option" SEC_GRP
Section /o "option 1" SEC_01
SectionIn 1
# option 1 files here
SectionEnd
Section /o "option 2" SEC_02
SectionIn 2
# option 2 files here
SectionEnd
SectionGroupEnd
Function .onSelChange
GetCurInstType $0
${if} $0 == 32
SectionGetFlags ${SEC_01} $1
IntOp $1 $1 & 1
${if} $1 == 1
SectionGetFlags ${SEC_02} $2
IntOp $2 $2 & 1
${andif} $2 == 1
MessageBox MB_OK "Only one option is allowed"
!insertmacro UnselectSection ${SEC_01}
!insertmacro UnselectSection ${SEC_02}
${endif}
${endif}
FunctionEnd
onad
20th March 2007 18:27 UTC
Red Wine you really are a "Major Dude" to (junior) forum members, great!
Red Wine
20th March 2007 18:57 UTC
Originally posted by onad
Red Wine you really are a "Major Dude" to (junior) forum members, great!
Thanks :)
I'm a kind of doorman, welcome the newbies showing 'em some passages to step inside ;)
pegase06
22nd March 2007 17:35 UTC
I have write :
outfile 'test.exe'
!include "Sections.nsh"
!include "LogicLib.nsh"
page components
page instfiles
var menu1
var menu2
SectionGroup /e "SectionGroup " SEC03
Section "Section 1" SEC031
;...
SectionEnd
Section /o "Section 2" SEC032
;...
SectionEnd
SectionGroupEnd
Function .onInit
StrCpy $menu1 1
StrCpy $menu2 0
FunctionEnd
Function .onSelChange
SectionGetFlags ${SEC031} $1
${if} $1 == 1
${AndIf} $menu1 != 1
!insertmacro UnselectSection ${SEC032}
StrCpy $menu1 1
StrCpy $menu2 0
${endif}
SectionGetFlags ${SEC032} $2
${if} $2 == 1
${AndIf} $menu2 != 1
!insertmacro UnselectSection ${SEC031}
StrCpy $menu1 0
StrCpy $menu2 1
${endif}
FunctionEnd
Works perfectly.
Mesial
18th August 2010 21:42 UTC
I have been struggling with this same issue for a while. Red Wine, you are a godsend for me. The code example you gave above gives the exact results I am looking for. But when I impliment it into my installer, that's when it gets complicated. I have 22 sections with some sections having over 50 choices. My goal is to allow the user to choose only one, but also the option not to choose any. Well actually, it gets complicated with the 9 install types...
Mesial
18th August 2010 23:28 UTC
I'll run to the library and upload a the installer to my site so you can see it action to get a better idea, for I am using my phone at the moment and I can't do things like thhat on here. I'll add a link to the script as it is too large to cut and paste here. This is the final issue that I have with this installer. People have been begging for this for over a year.
Mesial
24th August 2010 09:00 UTC
I have not needed to go to the library because i have gotten mine to work, too. But now i'm stumped on trying to get a section with more than two options to work properly. Let's say for example, i have four options in a section that the user can only choose one option, but can also choose none of them. Any one know how to modify pegase06's script (above)?
Mesial
25th August 2010 04:41 UTC
it's been 9 days that i have been trying to get this to work. I have been trying this so many different ways but just cant get the thing to work. The damned thing is, this whole project relies on this "choose only one or none" feature. I have accomplished every other requirement for this installer and I pray that this feature is not unobtainable.
MSG
25th August 2010 06:12 UTC
Come on, the solution is trivially simple. It's the same as the existing code, only with more ${If} ${ElseIf} {$Etc} in it.
http://nsis.pastebin.com/JigzyvmM
Mesial
25th August 2010 09:28 UTC
What might seem simple to you, i have been struggling with, call me stupid, call me slow, but it took me forever to figure this one out. I was just coming back to say that I have finally got it to work on multiple options, sorry to waste anyones time and I see your post. I wish i had a better internet connection than the cell phone i have been using for months... Dial-up would be like a 20meg broadband connection compared to this. I thank you for your response, i will follow your link and see how i might improve mine.